Skip to content

Instantly share code, notes, and snippets.

@oktavianto
Created October 12, 2022 11:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oktavianto/5b92174ed3dae411d9688261fc06b88b to your computer and use it in GitHub Desktop.
Save oktavianto/5b92174ed3dae411d9688261fc06b88b to your computer and use it in GitHub Desktop.
Buatlah program untuk menginput data sebanyak 5 mahasiswa (menggunakan array of structure)
#include <iostream>
#include <string>
using namespace std;
struct mahasiswa{
string nim;
string nama;
string jurusan;
};
int main(){
mahasiswa mhs[5];
for(int i=0; i<5; i++){
// [+] Input Data Masahasiswa ke - i [+]
cout << "[+] Masukkan Data Mahasiswa ke - " << i+1 << " [+]" << endl;
cout << "Masukkan NIM: ";
cin >> mhs[i].nim;
cout << "Masukkan Nama: ";
cin >> mhs[i].nama;
cout << "Masukkan Jurusan: ";
cin >> mhs[i].jurusan;
cout << "=========================" << endl;
}
cout << "NIM\tNama\tJurusan" << endl;
for(int i=0; i<5; i++){
cout << mhs[i].nim << "\t" << mhs[i].nama << "\t" << mhs[i].jurusan << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment