Breaking News
Loading...
Selasa, 22 Maret 2016

Menghitung Rata - Rata Nilai

Kemarin kita sudah tau bagaimana mendata mahasiswa sekarang kita menghitung rata - rata nilai mahasiswa dengan Dev C++ :

Dev C++ :

#include <iostream>
#include <windows.h>

/* 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 [10];
int i,jum=0,nilai [5];
int nim [9];
for (int i=1;i<=5;i++){
cout<<"No"<<i<<endl;
cout<<"Masukan Nim"<<i<<" : ";
cin>>nim[i];
cout<<"Masukan Nama"<<i<<" : ";
cin>>nama[i];
cout<<"Masukan Nilai"<<i<<" : ";
cin>>nilai[i];

}
system ("cls");
cout<<"\n"<<"No \t"<<" Nim \t" << "Nama \t"<<"Nilai \t"<<endl;
cout<<"------------------------------------"<<endl;
for(int i=1;i<=5;i++){
cout<<i<<"\t"<<nim[i]<<"\t"<<nama[i]<<"\t"<<nilai[i]<<endl;

}

cout<<"------------------------------------"<<endl;
cout<<"jumlah nilai = "<<nilai[1]+nilai[2]+nilai[3]+nilai[4]+nilai[5]<<"\n";
cout<<"rata-rata = "<<(nilai[1]+nilai[2]+nilai[3]+nilai[4]+nilai[5])/5<<"\n";
return 0;
}

Ini hasil Compilenya :


0 komentar:

Posting Komentar

Copyright © 2014 My Blog My Adventure All Right Reserved