Senin, 14 Maret 2016

MENGHITUNG DATA MAHASISWA

MENGHITUNG DATA MAHASISWA

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
string nama[5];
int no[5]={1,2,3,4,5};
int nim[5];
int nilai[5];
int jumlah;
for(int i=0;i<5;i++){
cout<<"masukan nama ke "<<i<<" : ";cin>>nama[i];
cout<<"masukan nim ke "<<" : ";cin>>nim[i];
cout<<"masukan nilai ke "<<" : ";cin>>nilai[i];
}
cout<<"------------------------------------------------------ "<<endl;
cout<<"no\t"<<"\tnama\t"<<"\tnim\t"<<"\tnilai\t"<<endl;
for(int i=0;i<5;i++){
cout<<no[i]<<"\t\t"<<nama[i]<<"\t\t"<<nim[i]<<"\t\t"<<nilai[i]<<"\t\t"<<endl;
jumlah=jumlah+nilai[i];
}
cout<<"-------------------------------------------------------"<<endl;
cout<<"\tjumlah ="<<jumlah<<endl;
double mean = jumlah/5;
cout<<"\trata-rata ="<<mean;
return 0;
}

Tidak ada komentar:

Posting Komentar