reels et condition

This commit is contained in:
moogin 2024-09-17 13:49:35 +02:00
parent 876c0f9964
commit fb69d789be
2 changed files with 87 additions and 0 deletions

50
DEV1.1/condition.c Normal file
View File

@ -0,0 +1,50 @@
# 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");
}
printf("%d\n", x);
return EXIT_SUCCESS;
}*/
int main(void){
int n = 0;
int num = 0;
double x = 0;
int table = 0;
printf("Entrez un réel : ");
n = scanf("%lf", &x);
num = x ;
table = num % 3;
if ( table == 2){
num = num + 1;
printf("%d \n", num);
}else if(table == 0){
printf("%d \n", num);
}else{
num = num - 1;
printf("%d \n", num);
}
}

37
DEV1.1/reels.c Executable file
View File

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
/*int main(void) {
printf("%.15f\n", 12345.678910111213);
return EXIT_SUCCESS;
}*/
/*int main(void) {
printf("%f\n", 5.0+2.5);
printf("%f\n", 5.0-2.5);
printf("%f\n", 5.0*2.5);
printf("%f\n", 5.0/2.5);
printf("%f\n", 5.0%2.5); #pb ici avec %
return EXIT_SUCCESS;
}*/
/*int main(void) { # ne foncitone pas car on divise par 0
printf("%f\n", +1.0/0.0);
printf("%f\n", -1.0/0.0);
printf("%f\n", -0.0/0.0);
return EXIT_SUCCESS;
}*/
int main(void) {
int n;
char lettre;
double x;
printf("Entrez un réel : ");
n = scanf("%lf", &x);
printf("son carré vaut : %f\n", x*x);
printf("entrer un caractère : ");
lettre = getchar();
lettre = getchar();
printf("j'ai lu : %c\n",lettre);
return EXIT_SUCCESS;
}