2021-10-12 09:38:38 +02:00
|
|
|
/* Calcul de la moyenne et de la somme */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int somme(int, int, int);
|
|
|
|
float moyenne(int, int, int);
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int var1, var2, var3, s;
|
|
|
|
float m;
|
|
|
|
|
2021-10-12 11:04:00 +02:00
|
|
|
printf("Entrez trois entiers (séparés par des espaces) : ");
|
|
|
|
scanf("%d %d %d", &var1, &var2, &var3);
|
2021-10-12 09:38:38 +02:00
|
|
|
|
|
|
|
s = somme(var1, var2, var3);
|
|
|
|
m = moyenne(var1, var2, var3);
|
|
|
|
|
|
|
|
printf(" Somme = %d\n", s);
|
|
|
|
printf(" Moyenne = %g\n", m);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int somme(int var1, int var2, int var3) {
|
|
|
|
return var1 + var2 + var3;
|
|
|
|
}
|
|
|
|
|
|
|
|
float moyenne(int var1, int var2, int var3) {
|
|
|
|
float total;
|
|
|
|
float moyenne;
|
|
|
|
|
|
|
|
total = somme(var1, var2, var3);
|
|
|
|
moyenne = total / 3;
|
|
|
|
|
|
|
|
return moyenne;
|
|
|
|
}
|