Page 89 - MODUL ALGORTIMA DAN PEMROGRAMAN
P. 89
cout<<"NIP :";cin>>dosen2.nip;
cout<<"Nama : ";fflush(stdin);
cin.get(dosen2.nama,30);
cout<<"Alamat : ";fflush(stdin);
cin.get(dosen2.alamat,50);
cout<<endl<<endl;
//output
cout<<"Data Dosen Pertama\n";
cout<<"---------------\n";
cout<<"NIP :"<<dosen1.nip<<endl;
cout<<"Nama : "<<dosen1.nama<<endl;
cout<<"Alamat : "<<dosen1.alamat<<endl;
cout<<endl<<endl;
cout<<"Data Dosen Pertama\n";
cout<<"---------------\n";
cout<<"NIP :"<<dosen2.nip<<endl;
cout<<"Nama : "<<dosen2.nama<<endl;
cout<<"Alamat : "<<dosen2.alamat<<endl;
cout<<endl<<endl;
return EXIT_SUCCESS;
}
Output:
Data Dosen Pertama
---------------
NIP :7006024
Nama : Adam Mukharil B
Alamat :Bandung
Data Dosen Kedua---------------
NIP :7006008
Nama : Dian Dharmayanti
Alamat : Bandung
Data Dosen Pertama
---------------
NIP :7006024
Nama : Adam Mukharil B
Alamat : Bandung
Data Dosen Kedua
---------------
NIP :7006008
Nama : Dian Dharmayanti
Alamat : Bandung
2. Contoh 2 – Program penggunaan union
66