fin TP
This commit is contained in:
27
DEV1.1/TP06/exo1.c
Normal file
27
DEV1.1/TP06/exo1.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int x=3;
|
||||
|
||||
if (x=2) {
|
||||
printf("x vaut 2\n");
|
||||
} else {
|
||||
printf("x est different de 2\n");
|
||||
}
|
||||
|
||||
printf("%d\n", x);
|
||||
|
||||
if (x=0) {
|
||||
printf("x vaut 0\n");
|
||||
} else {
|
||||
printf("x est different de 0\n");
|
||||
}
|
||||
|
||||
/* il se passe que lors du premier if x vaut 2 donc le programme prinf: x vaut 2
|
||||
et dans le second if x=0 ce qui vaut faut donc le programme print: x different de 0*/
|
||||
|
||||
printf("%d\n", x);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
18
DEV1.1/TP06/exo2.c
Normal file
18
DEV1.1/TP06/exo2.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
int n;
|
||||
int err;
|
||||
|
||||
printf("Entrer un entier naturel ");
|
||||
err= scanf("%d",&n);
|
||||
if ((n%3)<=1) {
|
||||
printf("le multiple le plus proche est : %d\n", (n /3)*3);
|
||||
} else {
|
||||
printf("%d\n",(n/3+1)*3);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user