If
SWITCH
do... while.
WHILE
for
Les instructions de branchement inconditionnel : break,
continue et goto
CONTINUE : ALLOWS US TO MOVE ON TO GO BACK TO THE START OF THE LOOP
BREAK : BREAKS A STRUCTURE
THE MAGIC GOTO :
- Code:
if (expression)
instruction_1
else if
instruction_2
else if ()
instruc3
SWITCH
- Code:
switch (n)
{ case 0 : printf ("nul\n") ;
[b]break ;[/b]
case 1 : printf ("un\n") ;
break ;
case 2 : printf ("deux\n") ;
break ;
[color=green][b]default : printf("not listed");[/b][/color]
}
do... while.
- Code:
main()
{
int n ;
do
{ printf ("donnez un nb >0 : ") ;
scanf ("%d", &n) ;
printf ("vous avez fourni %d\n", n) ;
}
while (n<=0) ;
WHILE
- Code:
while (expression)
instruction
for
- Code:
main()
{
int i ;
for ( i=1 ; i<=5 ; i++ )
{ printf ("bonjour ") ;
printf ("%d fois\n", i) ;
}
}
Les instructions de branchement inconditionnel : break,
continue et goto
CONTINUE : ALLOWS US TO MOVE ON TO GO BACK TO THE START OF THE LOOP
BREAK : BREAKS A STRUCTURE
THE MAGIC GOTO :
- Code:
main()
{
int i ;
for ( i=1 ; i<=10 ; i++ )
{ printf ("début tour %d\n", i) ;
printf ("bonjour\n") ;
if ( i==3 ) goto sortie ;
printf ("fin tour %d\n", i) ;
}
[b] sortie : printf ("après la boucle") ;
[/b]}