this is my code :
#include <iostream.h>its easy. isn't ?
#include <conio.h>
void main()
{
struct mahasiswa
{int nim;
char nama[30][1];
int nilai[3];
int tot;
};
int jml;
mahasiswa mhs[25];
mahasiswa tmp;
cout<<"Berapa jumlah mahasiswa : ";
cin>>jml;
for(int i=0;i<jml;i++)
{
mhs[i].tot=0;
cout<<"Nim : ";cin>>mhs[i].nim;
cout<<"Nama : ";cin>>mhs[i].nama[i];
for(int j = 0;j<3;j++)
{ cout<<"Nilai " <<(j+1)<<" : ";
cin>>mhs[i].nilai[j];
mhs[i].tot = mhs[i].tot + mhs[i].nilai[j];
}
}
clrscr();
for(int i=0;i<jml;i++)
{
cout<<"Nim : "<<mhs[i].nim<<endl;
cout<<"Nama : "<<mhs[i].nama[i]<<endl;
for(int j=0;j<3;j++)
{
cout<<"Nilai "<<(j+1)<<" : "<<mhs[i].nilai[j]<<endl;}
cout<<"Total : "<<mhs[i].tot<<endl<<endl;
}
getch();
}
Sign up here with your email
ConversionConversion EmoticonEmoticon