Solved

Using a loop to count by a decimal increment

Posted on 2003-10-29
4
673 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

762 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

20 Experts available now in Live!

Get 1:1 Help Now