#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
struct data
{
string nim[20],nama[80];
int i, menu;
};
data biodata;
void masukkan()
{
cout <<"Masukkan banyak data : ";cin>>biodata.i;
for(int a=1;a<=biodata.i;a++)
{
cout<<endl;
cout <<"Masukkan Nama : ";cin>>biodata.nama[a];
cout <<"Masukkan NIM : ";cin>>biodata.nim[a];
cout<<endl;
}
}
void tampil(){
cout<<"Cetak data diatas : "<<endl;
for(int a=1;a<=biodata.i;a++)
{
cout<<endl;
cout <<"Nama : "<<biodata.nama[a]<<endl;
cout <<"Nim : "<<biodata.nim[a]<<endl;
}
cout<<"-------------------"<<endl;
getch();
}
main()
{
cout<<"-------------------------------------"<<endl;
cout<<">>>>>MENGGUNAKAN STURCT DALAM C++<<<<"<<endl;
cout<<"-------------------------------------"<<endl;
do{//perulangan menggunakan do while
cout<<"-------------------"<<endl;
cout<<"1. Masukkan Data"<<endl;
cout<<"2. Cetak Data"<<endl;
cout<<"3. Keluar"<<endl;
cout<<"-------------------"<<endl;
cout<<"Pilih menu di atas : ";cin>>biodata.menu;
cout<<"Terimakasih"<<endl;
switch(biodata.menu){
case 1: masukkan();break;
case 2: tampil();break;
}
}while(biodata.menu!=3);
getch();
return 0;
}
Ingat y guys , jika ingin copas tolong disertakan sumbernya :D terimakasih . " Semoga Bermanfaat "
0 komentar:
Post a Comment