scriptnya :
#include<iostream.h>
int main()
{
int nilai,n,i,tot;
tot=0;
cout<<"Mochammad Robby Wibawa "<<endl;
cout<<"TI-111010 "<<endl;
cout<<"membuat program menghitung rata-rata " <<endl<<endl;
cout<<"masukkan jumlah data ";cin>>n;
for(i=1;i<=n;i++)
{cout<<"Masukkan nilai ke-"<<i<<": ";
cin>>nilai;
tot=tot+nilai;
}
cout<<"TOTAL NILAI= "<<tot<<endl;
cout<<"NILAI RATA-RATA= "<<tot/n<<endl;
}
hasilnya :
0 komentar:
Posting Komentar