how to use a for loop?

Feb 2, 2012 at 3:28am
Hello I am glad to be a member of this forum.
I have a little problem starting this problem.

"Develop a compound interest program to repeat its steps from interest rate of 5 percent, 6 percent, 7 percent, 8 percent, 8 percent, and 10 percent. Use a for loop to vary the interest rate. "

If anyone could help me I would appreciate it.
Thanks
Feb 2, 2012 at 3:35am
Did you mean 5, 6, 7, 8, NINE, 10? ;)

Here is how you use a for loop:
for(pre-loop setup; loop condition; loop action)

Most commonly you will see this:
for(unsigned long i = 0; i < some_value; ++i)
Which loops through every value between [0, some_value)

This is an infinite loop:
for(;;)
As you can see all statements are optional.

Check here: http://www.cplusplus.com/doc/tutorial/control/#for
Last edited on Feb 2, 2012 at 3:36am
Feb 2, 2012 at 3:37am
is that the whole problem?
Feb 2, 2012 at 6:17am
1
2
3
4
for (int i=5; i < 11; i++)
{
    cout << "Your equation here, using i as the interest rate" << endl;
}
Feb 2, 2012 at 3:13pm
Yes it's 5,6,7,9,10..
Thank you!
Feb 2, 2012 at 4:44pm
You mean 5, 6, 7, EIGHT, 9 10? ;)
Feb 2, 2012 at 4:49pm
@L B

Haha, that made me chuckle. #define PEDANTIC
Topic archived. No new replies allowed.