Created
February 25, 2020 05:07
-
-
Save nonohry/4a30825ea9a17a4c34493ed2976030b4 to your computer and use it in GitHub Desktop.
Data Mahasiswa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <conio.h> | |
using namespace std; | |
//Deklarasi struct | |
struct data_mahasiswa | |
{ | |
long int nim; | |
char nama[100]; | |
char fakultas[100]; | |
}; | |
//Deklarasi variabel struct | |
data_mahasiswa mahasiswa1, mahasiswa2; | |
int main() | |
{ | |
//Input struct data mahasiswa | |
cout<<" Data Mahasiswa Pertama\n"; | |
cout<<"-----------------------\n"; | |
cout<<" NIM : "; cin>>mahasiswa1.nim; | |
cout<<" Nama : "; fflush(stdin); gets(mahasiswa1.nama); | |
cout<<" Fakultas : "; fflush(stdin); gets(mahasiswa1.fakultas); | |
cout<<"\n\n"; | |
cout<<" Data Mahasiswa Kedua\n"; | |
cout<<"-----------------------\n"; | |
cout<<" NIM : "; cin>>mahasiswa2.nim; | |
cout<<" Nama : "; fflush(stdin); gets(mahasiswa2.nama); | |
cout<<" Fakultas : "; fflush(stdin); gets(mahasiswa2.fakultas); | |
cout<<"\n\n"; | |
//Output struct data mahasiswa | |
cout<<" Data Mahasiswa Pertama\n"; | |
cout<<"-----------------------\n"; | |
cout<<" NIM : "<<mahasiswa1.nim<<endl; | |
cout<<" Nama : "<<mahasiswa1.nama<<endl; | |
cout<<" Fakultas : "<<mahasiswa1.fakultas<<endl; | |
cout<<"\n\n"; | |
cout<<" Data Mahasiswa Kedua\n"; | |
cout<<"----------------------\n"; | |
cout<<" NIM : "<<mahasiswa2.nim<<endl; | |
cout<<" Nama : "<<mahasiswa2.nama<<endl; | |
cout<<" Fakultas : "<<mahasiswa2.fakultas<<endl; | |
cout<<"\n\n"; | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment