Solved

Using a loop to count by a decimal increment

Posted on 2003-10-29
4
675 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
  • 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 50 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to split this in C++ 4 101
Least Squares Curve Fitting 4 77
Microsoft C++ code failing in executable that worked 9 97
show out valin of json for debugging in visaul c++ 1 31
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now