{
/* block */
printf("hello");
}
for (...)
printf("") // compound statement
if (expression)
statement1
else
statement2
if (expression)
statement
else if(expression)
statement
else if(expression)
statement
else
statement
Exercice :
switch (expression)
case const-expr: statements
case const-expr: statements
default: statements
Exercice :
while (expression)
statement
for (expr1; expr2; expr3)
statement
// equivalent to
expr1;
while (expr2)
{
statment
expr3;
}
Exercice :
do
statement
while (expression);
break
exit from for, while, and do while
continue
go to the next iteration of for, while, do
for (i + 0; i < n; i++)
if (a[i] < 0) /* skipe negative elements */
continue;
/* do positive elements */
for (...)
for (...)
if (disaster)
goto error;
error:
clean up the mess
real example :
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
if (a[i] == b[j])
goto found;
/* didn't find any common element */
found
/* got one: a[i] == b[j]*/