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
Solved

Using a loop to count by a decimal increment

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
returning a dereferenced pts in C++ 10 158
HTTPSendRequest with WinINet delays on first call 11 34
Android development question 2 54
Outlook 13 41
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

828 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