#Meta-Wlp: #Macro: TITLE wlp: Learn C (II) p. 5
Remember: the structure of the while statement is:
while ( control ) {
statements }
If there is a single statement, the curly braces are not needed. Curly braces collect statements together into compound statements. Compound statements can placed anywhere a single statement might placed.
What does this program do?
#include<stdio.h> int main(){ int i, j ; /* It's OK to put two declarations together */ i = ( j = 1 ) ; while ( 1==1 ) { printf( "%d\n", i ) ; i += ( j += 2 ) ; } printf("Good-bye cruel world!\n") ; }How does this program fix the comma problem, #Shuffle: none $PAGE$-A $PAGE$-B $PAGE$-C Return to Learn C Introduction #: It prints Good-bye cruel world! #: It loops forever, printing consecutive squares 1, 4, 9, ... #: It counts by 2 until i is equal to j. #: