Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define PI 3.1416
- void exo3()
- {
- int int_size = sizeof(int);
- int short_size = sizeof(short);
- int char_size = sizeof(char);
- int float_size = sizeof(float);
- int double_size = sizeof(double);
- printf("int: %d\nshort: %d\nchar: %d\nfloat: %d\ndouble: %d\n",
- int_size, short_size, char_size, float_size, double_size);
- }
- void exo4_1()
- {
- int a,b;
- printf("Entrer a puis b deux entiers.\n");
- scanf("%d", &a);
- scanf("%d", &b);
- float quotient = a/b;
- printf("a+b=%d\n", a+b);
- printf("a-b=%d\n", a-b);
- printf("a*b=%d\n", a*b);
- printf("a/b=%.0f\n", quotient);
- printf("a%b=%d", a%b);
- }
- void exo4_2()
- {
- float a,b;
- printf("Entrer les valeurs a et b a permuter.\n");
- scanf(" %f", &a);
- scanf(" %f", &b);
- float temp = a;
- a = b;
- b = temp;
- char c, d;
- printf("Entrer les deux caracteres a permuter.\n");
- getchar();
- c = getchar();
- printf("so c=%c\n", c);
- getchar();
- d = getchar();
- printf("so d=%c\n", d);
- char temp2 = c;
- c = d;
- d = temp2;
- printf("a=%f, b=%f, c=%c, d=%c", a, b, c, d);
- }
- void exo4_3()
- {
- char a, b;
- printf("Entrer deux caracteres.\n");
- a = getchar();
- getchar();
- b = getchar();
- char c = a - b;
- char d = a + b;
- printf("a - b = %c", c); //Affiche résultat de la soustraction de la valeur ASCII des caracteres
- printf("a + b = %c", d); //Affiche résultat de l'addition de la valeur ASCII des caractères
- }
- void exo4_4()
- {
- float a, b;
- printf("Entrer deux valeurs reelles.\n");
- scanf("%f", &a);
- scanf("%f", &b);
- float max = a>=b ? a : b;
- float min = a<b ? a : b;
- printf("max:%f\nmin:%f", max, min);
- }
- void exo5()
- {
- int b, h;
- printf("Entrer la longueur de la base, puis de la hauteur.\n");
- scanf("%d", &b);
- scanf("%d", &h);
- float a = (float)1/2* b * h;
- printf("A = %.2f", a);
- }
- void exo6()
- {
- printf("PI = %f\n", PI);
- int r, h;
- printf("Entrer le rayon puis la hauteur.\n");
- scanf("%d", &r);
- scanf("%d", &h);
- float b = (float)PI * r * r;
- float v = (float)1/3 * b * h;
- printf("V = %.2f", v);
- }
- int main()
- {
- exo3();
- exo4_1();
- exo4_2();
- exo4_3();
- exo4_4();
- exo5();
- exo6();
- return 0;
- }
Add Comment
Please, Sign In to add comment