Add geometrie3d
This commit is contained in:
parent
fd04b9b3f0
commit
6ce1ed4c32
2 changed files with 57 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
all: convertisseur-devises inversion-variables moyenne-somme geometrie2d
|
||||
all: convertisseur-devises inversion-variables moyenne-somme geometrie2d geometrie3d
|
||||
|
||||
convertisseur-devises: convertisseur-devises.c
|
||||
cc convertisseur-devises.c -o convertisseur-devises
|
||||
|
@ -12,5 +12,8 @@ moyenne-somme: moyenne-somme.c
|
|||
geometrie2d: geometrie2d.c
|
||||
cc geometrie2d.c -o geometrie2d
|
||||
|
||||
geometrie3d: geometrie3d.c
|
||||
cc geometrie3d.c -o geometrie3d
|
||||
|
||||
clean:
|
||||
rm -f convertisseur-devises inversion-variables moyenne-somme geometrie2d
|
||||
rm -f convertisseur-devises inversion-variables moyenne-somme geometrie2d geometrie3d
|
||||
|
|
52
programmation-c-cpp/tp1/geometrie3d.c
Normal file
52
programmation-c-cpp/tp1/geometrie3d.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Géométrie 3D */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define PI 3.14
|
||||
|
||||
int calcul_diametre(int);
|
||||
float calcul_circonference(int);
|
||||
float calcul_aire(int);
|
||||
float calcul_volume(float, int);
|
||||
|
||||
int main() {
|
||||
int rayon, hauteur, diametre;
|
||||
float circonference, aire, volume;
|
||||
|
||||
printf("Quel est le rayon du cercle ? ");
|
||||
scanf("%d", &rayon);
|
||||
|
||||
diametre = calcul_diametre(rayon);
|
||||
circonference = calcul_circonference(diametre);
|
||||
aire = calcul_aire(rayon);
|
||||
|
||||
printf(" Diamètre = %d\n", diametre);
|
||||
printf(" Circonférence = %g\n", circonference);
|
||||
printf(" Aire = %g\n", aire);
|
||||
|
||||
printf("Quelle est la hauteur du cylindre ? ");
|
||||
scanf("%d", &hauteur);
|
||||
|
||||
volume = calcul_volume(aire, hauteur);
|
||||
|
||||
printf(" Volume = %g\n", volume);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int calcul_diametre(int rayon) {
|
||||
return 2 * rayon;
|
||||
}
|
||||
|
||||
float calcul_circonference(int diametre) {
|
||||
return PI * diametre;
|
||||
}
|
||||
|
||||
float calcul_aire(int rayon) {
|
||||
return PI * rayon * rayon;
|
||||
}
|
||||
|
||||
float calcul_volume(float aire, int hauteur) {
|
||||
return aire * hauteur;
|
||||
}
|
Loading…
Reference in a new issue