Buat adik2 mahasiswa yg kesulitan mengerti apa itu struct......yuukk mari kita lihat program di bawah....!!!!
tapi jagn copas doank....dalami resapi dan rasakan...hahahah
#include <conio.h>
#include <iostream.h>
#include <stdio.h>
main(){
float tot,ip;
struct mahasiswa{
char nim[12];
char nama[15];
char kelas[15];
int smt;
}mhs;
struct KartuHasilStudi{
char no[12];
char smt[15];
char th[15];
int jmk;
}khs;
struct mk{
char ko[12];
char nmk[15];
int sks;
int nilai;
}mk;
cout<<"\nmasukkan NIM = ";cin>>(mhs.nim);
cout<<"\nmasukkan Nama Mahasiswa =";gets(mhs.nama);
cout<<"\nmasukkan kelas = ";gets(mhs.kelas);
cout<<"\nmasukkan jml semester ="; cin>>(mhs.smt);
cout<<"==============================="<<endl;
for(int i=1;i<=mhs.smt;i++)
{
cout<<"==============================="<<endl;
cout<<"\nmasukkan no KHS =";cin>>(khs.no);
cout<<"\nmasukkan semester =";cin>>(khs.smt);
cout<<"\nmasukkan tahun =";gets(khs.th);
cout<<"\nmasukkan jumlah mata kuliah =";cin>>khs.jmk;
cout<<"==============================="<<endl;
for(int a=1;a<=khs.jmk;a++)
{
cout<<"\nmasukkan kode mata kuliah =";gets(mk.ko);
cout<<"\nmasukkan nama MK =";gets(mk.nmk);
cout<<"\nmasukkan sks =";cin>>mk.sks;
cout<<"\nmasukkan nilai =";cin>>mk.nilai;
cout<<"==============================="<<endl;
}}
cout<<"==============================="<<endl;
cout<<"==============================="<<endl;
cout<<" Data Akhir mahasiswa\n"<<endl;
cout<<"\n NIM =\n"<<(mhs.nim);
cout<<"\n Nama Mahasiswa =\n"<<(mhs.nama);
cout<<"\n Kelas =\n"<<(mhs.kelas);
tot=mk.sks*khs.jmk;
ip=(mk.nilai*mk.sks)/tot;
cout<<"\n IPK =\n"<<ip;
getch();
}
0 komentar:
Posting Komentar