53 lines
1 KiB
C
53 lines
1 KiB
C
|
/* 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;
|
||
|
}
|