This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP3/E3.c
2016-03-09 08:26:25 +01:00

37 lines
674 B
C

/* Moyenne */
#include <stdio.h>
double moyenne(int n, double T[n]) {
int i;
double tot = 0;
for (i = 0; i < n; i++) {
tot += T[i];
}
return tot/n;
}
double maximum(int n, double T[n]) {
int i;
double max = T[0];
for (i = 0; i < n; i++) {
if (T[i] > max) {
max = T[i];
}
}
return max;
}
int main() {
int n, i;
printf("Nombre de nombres ? ");
scanf("%d", &n);
double T[n];
for (i = 0; i < n; i++) {
printf("Saisir le nombre %d : ", i+1);
scanf("%lf", &T[i]);
}
printf("Moyenne : %lf\n", moyenne(n, T));
printf("Maximum : %lf\n", maximum(n, T));
}