Solution for Exercise 11-10
ex1110
#include <stdio.h>
int main()
{
int cinq;
for(cinq=5;cinq<101;cinq+=5)
printf("%d\n",cinq);
return(0);
}
Output
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
Notes
* As with pervious Exercises, you need not match my variable names or even some specifics. The key is the third condition in the for statement, which uses the += assignment operator to step through the loop in increments of 5 (Line 7).
* You could have also expressed the middle part of the for statement as cinq<=100.
* More power to you if you chose to perform this same operation by using a while loop instead of a for loop. In fact, if you need practice, make this task a bonus exercise: Re-write the same code using a while loop.
Copyright © 1997-2026 by QPBC.
All rights reserved
