Contoh Materi Array

#include <iostream.h>

const Mhs = 10;

int Nilai [Mhs];
void Tulis_Nilai_Rata2(const Nilai);

int main()
{ int Nilai_konte, konte;
Nilai_konte;
cout << “Masukkan ” <<Mhs<< “Nilai Tiap Mahasiswa : “<<endl;
/*baca(konte);*/
cout << “Nilai rata-rata nialai : “<< endl;
Tulis_Nilai_Rata2(konte);
}
void baca(Nilai_konte)
{float konte; int Mk=4;
for (int i=0; i<Mhs; i++)
{ cout << “Mahasiswa “<<i<< ” : “;
for (int j=0;j<Mk;j++)
cin >> konte([i][j]);
}
}
void Tulis_Nilai_Rata2(Nilai_Konte)
{float sum, konte; int Mk=4;
for (int i=0; i<Mk; i++)
{sum =0.0;
for (int j=0;j<Mhs; j++)
sum += konte([j][i]);
cout << “Mahasiswa ” << i << ” : ” << sum/Mhs<< endl;
}
}

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s