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); }
Notes
* As with pervious answers, you don't have to 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 that task a bonus exercise.
Copyright © 1997-2024 by QPBC.
All rights reserved