Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Exercice 1 :

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
int a ;
int b ;
int main(int argc, char *argv[]) {

printf("donner le premier nombre : ");


scanf("%d",&a);

printf("donner le deuxieme nombre : ");


scanf("%d",&b);

if ( a < b ){
printf("le minimum est : %d ",a);}
else {
printf("le minimum est : %d ",b);
}

getch();
return 0;
}

Exercice 2 :

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
int a ;
int b = -1 ;
void absolu () ;
int main(int argc, char *argv[]) {
absolu () ;

getch();
return 0;
}

void absolu (){


printf("donner un nombre : ");
scanf("%d",&a);

if ( a < 0 ){
printf("le nombre absol� est : %d ",a * b);}
else {
printf("le nombre est : %d ",a);
}

exercice 3 :

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
int T[22];
int a = 3 ;
int i ;
int main(int argc, char *argv[]) {
for (i=0 ; i <= 20 ; i++ ){

printf ("le nombre T[%d] : ",i);


scanf ("%d",&T[i]);
}
for (i=0 ; i < 20 ; i ++ ){
printf("\n le nombre est %d",a);
}
getch();
return 0;
}

exercice 4 :

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
int T[6];
int a = 3 ;
int i ;
int somme ;
int moyenne ;
int max = 0 ;
int main(int argc, char *argv[]) {
for (i=0 ; i < 6 ; i++ ){

printf ("le nombre T[%d] : ",i+1);


scanf ("%d",&T[i]);
somme = T[i] + somme ;

if ( T[i] > max ){


max = T[i] ;}

}
printf ("la somme est : %d ",somme);
moyenne = somme /T[i] ;
printf ("\nla moyenne est : %d ",moyenne);
printf ("\nle max est : %d ",max);
getch();
return 0;
}

You might also like