Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define Nmaks 100
- typedef struct {
- int NIM;
- char NamaMhs[20];
- float IPK;
- }Mahasiswa;
- typedef Mahasiswa TabMhs[Nmaks];
- void BacaDataMahasiswa(int N, TabMhs Mhs);
- void CetakDatamahasiswa(int N, TabMhs Mhs);
- int main()
- {
- int n;
- TabMhs B;
- TabMhs C;
- std::cout << "n : ";
- std::cin >> n;
- BacaDataMahasiswa(n, B);
- CetakDatamahasiswa(n, C);
- return 0;
- }
- void BacaDataMahasiswa(int N, TabMhs Mhs)
- {
- int i;
- for (i=0; i<=N-1; i++)
- {
- std::cout << "Data - " << i + 1 << std::endl;
- std::cout << "NIM : ";
- std::cin >> Mhs[i].NIM;
- std::cout << "Nama : ";
- std::cin >> Mhs[i].NamaMhs;
- std::cout << "IPK : ";
- std::cin >> Mhs[i].IPK;
- std::cout << std::endl;
- }
- }
- void CetakDatamahasiswa(int N, TabMhs Mhs)
- {
- int j;
- std::cout << "NIM " << "Nama Mahasiswa " << " IPK" << std::endl;
- for (j=0; j<=N-1; j++)
- {a
- std::cout << Mhs[j].NIM << " " << Mhs[j].NamaMhs << " " <<Mhs[j].IPK << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement