Program Mencari Nilai Rata-rata
#include <stdio.h>
#include <conio.h>
float nilai[100];
int n, i;
float rerata, sum;
main ()
{
printf("Silahkan masukan jumlah data : ");
scanf("%d", &n);
for(i=0; i<=n-1; i++)
{
printf("Data ke %d: ", i+1);
scanf("%f", &nilai[i]);
sum+=nilai[i];
}
rerata = sum / n;
printf("Rerata: %.3f", rerata);
getch();
return 0;
}
hasil
No comments:
Post a Comment