Menghitung nilai rata-rata

Berikut program c++ menghitung nilai mhs :

#include <iostream>
#include <conio.h>
using namespace std;

main(){
int i,nilai_mhs[10];
float rata,jumlah;
cout<<"Menghitung nilai mahasiswa : "<<endl;
i=1;
while(i<=10){
cout<<"Masukkan nilai mahasiswa ke "<<i<<" : ";
cin>>nilai_mhs[i];
jumlah=jumlah+nilai_mhs[i];
i+=1;
}
rata=jumlah/10;
cout<<"Jumlah Nilai = "<<jumlah<<"\n";
cout<<"rata-rata nilai ="<<rata;

getch();
}

output :



Share this

Related Posts

Previous
Next Post »

2 komentar

komentar
7 March 2016 at 08:07 delete

wihh mesti banyak belajar lagi nih kalo mau main gituan :D

Reply
avatar
8 March 2016 at 07:03 delete

iya gan sama sama lagi belajar

Reply
avatar