#include <iostream.h>
#include <conio.h>
void main(){
float nilai[5];
float jumlah, rata2;
cout<<"Program Menghitung Nilai Rata-rata"<<endl;
for(int i=0; i<5; i++)
{
cout<<"Masukkan nilai ke "<<(i+1)<<" : ";
cin>>nilai[i];
}
jumlah = 0;
for(int i=0; i<5; i++)
{
jumlah = jumlah + nilai[i];
}
rata2 = jumlah / 5;
cout<<"Nilai rata-rata adalah "<<rata2<<endl;
getch();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment