Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using a loop to count by a decimal increment

Posted on 2003-10-29
4
Medium Priority
?
681 Views
Last Modified: 2012-06-22
I'm trying to make a loop that counts by .8, ie- user enters a starting digit, it takes that number and counts by .8 for a set ammount of times... I have already found one way to do it but im sure there has to be another because this one takes alot of effort, and display variables...


any tips will be appreciated
0
Comment
Question by:canucks16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 9643724
If you can use float you could do something like:

float lv;
cin>>lv;
for( ; lv<limit; lv+=0.8)
{   //loop code
}
0
 
LVL 12

Accepted Solution

by:
andrewjb earned 100 total points
ID: 9643896
or do you mean

int lIndex;
float lValue;

lValue = //start value

for ( lIndex = 0 ; lIndex < lCount ; lIndex++ , lValue+=0.8)
{
  // use lValue here
}

?? What's the problem?
0
 
LVL 16

Expert Comment

by:imladris
ID: 9651167
Did either of those answers help?

If so it is time to select one to close the question, and grade it.

If not, perhaps a clarifying question would help.
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 9656467
If that answer is right, don't 'C' grade it. If it isn't, say why. People get annoyed with low grades...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question