1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| #include <stdio.h>
#include <stdlib.h>
#include <math.h>
main()
{
int i,nb,tot;
float som,moy;
som=0;
moy=0;
i=0;
nb=0;
tot=0;
printf("entrer le nombre de chiffre a additionner :");
scanf("%d", &nb);
puts ("\n\n\n");
for(i=0;i<nb;i++)
{
printf("entrer la valeur de la cellule %i du tableau : ",i+1);
scanf("%i", &tot);
}
puts ("\n\n\n");
som = som + tot;
printf("la somme est egale a : %g",som);
puts ("\n\n\n");
moy = moy + (som/nb);
printf("la moyenne est egale a : %g",moy);
puts ("\n\n\n");
system("pause");
return 0;
} |
Partager