Advertisement
titoxcodexx

structc++

Oct 31st, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. struct mahasiswa
  7. {
  8.     char nim[9];
  9.     char nama [25];
  10.     char alamat [40];
  11.     short umur;
  12. };
  13. main ()
  14. {
  15.     mahasiswa mhs;
  16.     cout<<"NIM    : ";
  17.     cin.getline(mhs.nim,9);
  18.     cout<<"Nama   : ";
  19.     cin.getline(mhs.nama,25);
  20.     cout<<"Alamat : ";
  21.     cin.getline(mhs.alamat,40);
  22.     cout<<"Umur   : ";
  23.     cin>>mhs.umur;
  24.  
  25.     cout<<"\n\n\nNIM    : "<<mhs.nim;
  26.     cout<<"\nNama   : "<<mhs.nama;
  27.     cout<<"\nAlamat : "<<mhs.alamat;
  28.     cout<<"\nUmur   : "<<mhs.umur;
  29.     getch();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement