Fin TP10
This commit is contained in:
62
DEV1.1/TP10/TP10_reponses.txt
Normal file
62
DEV1.1/TP10/TP10_reponses.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
-------- TP10 : Types --------
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
printf("%d\n", 77);
|
||||
printf("%c%c\n", '7', '7');
|
||||
printf("%hd\n", 77);
|
||||
printf("%u\n", 77U);
|
||||
printf("%ld\n", 77L);
|
||||
printf("%lu\n", 77UL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
-------------------------------
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int valeur;
|
||||
char texte;
|
||||
printf("Entier : ");
|
||||
scanf("%d", &valeur);
|
||||
texte = (char) valeur;
|
||||
printf("%c", texte);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Lorsque l'on passe d'un int à un char, le char prend comme valeur
|
||||
le numéro du caractère ASCII correspondant à l'int converti.
|
||||
|
||||
-----------------------------
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int lundi;
|
||||
int mardi;
|
||||
int mercredi;
|
||||
int jeudi;
|
||||
int vendredi;
|
||||
printf("1er jour : ");
|
||||
scanf("%d", &lundi);
|
||||
getchar();
|
||||
printf("\n2e jour : ");
|
||||
scanf("%d", &mardi);
|
||||
getchar();
|
||||
printf("\n3e jour : ");
|
||||
scanf("%d", &mercredi);
|
||||
getchar();
|
||||
printf("\n4e jour : ");
|
||||
scanf("%d", &jeudi);
|
||||
getchar();
|
||||
printf("\n5e jour : ");
|
||||
scanf("%d", &vendredi);
|
||||
printf("\nMoyenne : %.2f", (double) (lundi + mardi + mercredi + jeudi + vendredi) / 5);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
26
DEV1.1/TP10/tests.c
Normal file
26
DEV1.1/TP10/tests.c
Normal file
@@ -0,0 +1,26 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int lundi;
|
||||
int mardi;
|
||||
int mercredi;
|
||||
int jeudi;
|
||||
int vendredi;
|
||||
printf("1er jour : ");
|
||||
scanf("%d", &lundi);
|
||||
getchar();
|
||||
printf("\n2e jour : ");
|
||||
scanf("%d", &mardi);
|
||||
getchar();
|
||||
printf("\n3e jour : ");
|
||||
scanf("%d", &mercredi);
|
||||
getchar();
|
||||
printf("\n4e jour : ");
|
||||
scanf("%d", &jeudi);
|
||||
getchar();
|
||||
printf("\n5e jour : ");
|
||||
scanf("%d", &vendredi);
|
||||
printf("\nMoyenne : %.2f", (double) (lundi + mardi + mercredi + jeudi + vendredi) / 5);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user