Solved

Using a loop to count by a decimal increment

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 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

23 Experts available now in Live!

Get 1:1 Help Now