Vous êtes sur la page 1sur 2

types non variables;

nom -variable= valeur d'initialisation;


int age;//déclaration
age=37;// initialisation
type nom-variable= valeur d'initialisation;
int age=37;
types
int
float
double
char
structured de controles
conditionnelles ou test
if-else;if-else-if-else;switch-case
switch-case
switch(variable)
{
case valeur: instruction 1; break;
case valeur: instruction 2; break;
.
.
.
.
case valeur: instruction n; break;
default: instruction n+1;
ex
int valeur;
printf("entrer une valeur comprise entre 0 et 4");
scanf("%d",&valeur);
switch(valeur)
{
case 0:printf("vous avez entrée 0"); break;
case 1:printf("vous avez entrée 1"); break;
case 2:printf("vous avez entrée 2"); break;
case 3:printf("vous avez entrée 3"); break;
case 4:printf("vous avez entrée 4"); break;
default: printf("vous n'avez pas entrée la valeur demandé");
structures de repetition
for, while, do-while
for(variable=valeur;critère d'arret; incrementation)
{
instruction 1;
.
.
.
.
.
instruction n;
}
ex
int age=10;
int i;
for(i=0;i<3;i++)
printf("la valeur de age est %d",age+i);

while
while(condition)
{
instruction 1;
instruction 2;
.
.
.
.
instruction n;
}
int age=10;
while(age<15)
{
printf("la valeur de l'age est:%d",age+1);
age++
}
do-while
do
{
instruction 1;
.
.
.
.
.
instruction n;
} while(condition);

Vous aimerez peut-être aussi