Program Mencari Rata-rata (Dev C++)
#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 Compile
Semoga bermanfaat :)
0 komentar
Posting Komentar