for loops

Can somebody show me how to do this with steps? not understanding it, i have a test tomorrow!!

Determine the value in total after each of the following loops is executed:

a. total = 0;
for (i = 1; i <= 10; i = i + 1)
total = total + 1;

b. total = 1;
for (count = 1; count <= 10; count = count + 1)
total = total * 2;

c. total = 0
for (i = 10; i <= 15; i = i + 1)
total = total + i;

d. total = 50
for (i = 1; i <=10; i = i + 1)
total = total – i;

e. total = 1
for (icnt = 1; icnt <= 8; ++icnt)
total = total * icnt;

f. total = 1.0
for (j = 1; j <= 5; ++j)
total = total / 2.0;

I don't need a program just how to get the values. Thanks!!
http://www.cplusplus.com/doc/tutorial/control/#for

If you don't want to learn how loops work, you could always just paste the code in a program and print the result...
Last edited on
From my understanding, I will try and show you how to do the first one.

I am going off of a. for this.

Basically what is happening, is to begin with, total = 0 . Using a for loop, you are looping 'i' which is equal to 1 until it is no longer less than or equal to 10. Each time this loops, which will be 10 times I believe, it adds 1 to total. So if this loops 10 times, it will make total equal to 10.

Sorry if this is a crappy explanation. Running on 3 hours of sleep today. Just thought I would try and help since your test is tomorrow and nobody else has answered.

Topic archived. No new replies allowed.