How to create this program ?

Add 3% to 17810(to get new answer) and then again add 3% to the new answer.
Continue till 8 times.
Last edited on
Use a loop of some sort (while, and for) would be best suited for this task.

Also, what is the 3% for? 3% of what?

Cheers,
Joe
Thanks for replying, i want to add 3% of 17810 to itself (that is 17810). And repeat this upto 8th time.
Basically i want (say x)
x1=17810+0.03*17810
and then
x2=x1+0.03*x1
and repeat it till x8

Please can you explain in detail as i am new to c language.
You want to use either a for loop or a while loop that iterates 8 times. The for loop would probably be best suited for your problem. As for the math.
Setting a variable equal to the initial amount of 17810 and then adding 3% of that to itself would be a good way to do it.
1
2
3
4
5
6
//something like this.
double amount = 17810;
//math would like this.
amount = amount + (amount * .03);
//or
amount += amount * .03;


http://www.cplusplus.com/doc/tutorial/control/
Link should help you with for loops and while loops.
Last edited on
Topic archived. No new replies allowed.