Wednesday, April 9, 2014

Contoh Program C++ Hitung Data Nilai Siswa





Contoh Program C++ Hitung Data Nilai Siswa
#include
#include
#include
#include

int data_nilai[2][10];

void isi_data(int nilai[2][10]);
void cetak_data(int nilai[2][10]);
int tertinggi(int nilai[2][10],int x);
int tertinggi_all(int nilai[2][10]);

void main()
{
cout << "===============================" << endl;
    cout << "Program Hitung Data Nilai Siswa" << endl;
cout << "===============================" << endl;
cout <<"By :Devia Christa"<
cout << endl;
int nilai[2][10],x;
isi_data(nilai);
cetak_data(nilai);
cout << "Nilai Tertinggi kelas 1 = " << tertinggi(nilai,0) << endl;
cout << "Nilai Tertinggi kelas 2 = " << tertinggi(nilai,1) << endl;
cout << "Nilai Tertinggi semua kelas = " << tertinggi_all(nilai) << endl;
cout << endl;
cout << "Tekan sembarang tombol untuk keluar";
getch();
}

void isi_data(int nilai [2][10])
{
      randomize();
for(int k=0;k<10 div="" k="">
{
  nilai[0][k] = random(101);
  nilai[1][k] = random(101);
}
}
void cetak_data(int nilai[2][10])
{
  for(int m=0;m<2 div="" m="">
  {
cout << "Pelajaran" << (m+1)<< ":" << endl;
for(int k=0;k<10 div="" k="">
 cout << (k+1) << ":" << nilai[m][k] << " ";
    cout << endl;
  }
}

int tertinggi(int nilai[2][10],int x)
{
int t = nilai[x][0];
for (int k=1; k<10 div="" k="">
 if (nilai[x][k] > t)
    t = nilai[x][k];
    return t;
}
int tertinggi_all (int nilai[2][10])
{
int t = nilai[0][0];
for (int x=0;x<2 div="" x="">
{
 for (int k=1; k<10 div="" k="">
 if (nilai[x][k] > t)
    t = nilai[x][k];
}
    return t;
}

No comments :

Post a Comment

Kebahagiaan sejati bukanlah pada saat kita berhasil meraih apa yg kita perjuangkan, melainkan bagaimana kesuksesan kita itu memberi arti atau membahagiakan orang lain.

Follower

Google+ Followers

Translator

English French German Japanese Korean Chinese Russian Spanish
India Saudi Arabia Netherland Portugal Italian Philippines Ukraina Norwegia
Powered by
Widget translator