Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #define Nmaks 100
  3.  
  4. typedef struct {
  5.  
  6. int NIM;
  7. char NamaMhs[20];
  8. float IPK;
  9.  
  10. }Mahasiswa;
  11.  
  12. typedef Mahasiswa TabMhs[Nmaks];
  13.  
  14. void BacaDataMahasiswa(int N, TabMhs Mhs);
  15. void CetakDatamahasiswa(int N, TabMhs Mhs);
  16.  
  17. int main()
  18. {
  19. int n;
  20. TabMhs B;
  21. TabMhs C;
  22. std::cout << "n : ";
  23. std::cin >> n;
  24. BacaDataMahasiswa(n, B);
  25. CetakDatamahasiswa(n, C);
  26. return 0;
  27. }
  28.  
  29. void BacaDataMahasiswa(int N, TabMhs Mhs)
  30. {
  31. int i;
  32. for (i=0; i<=N-1; i++)
  33. {
  34. std::cout << "Data - " << i + 1 << std::endl;
  35. std::cout << "NIM : ";
  36. std::cin >> Mhs[i].NIM;
  37. std::cout << "Nama : ";
  38. std::cin >> Mhs[i].NamaMhs;
  39. std::cout << "IPK : ";
  40. std::cin >> Mhs[i].IPK;
  41. std::cout << std::endl;
  42. }
  43. }
  44.  
  45. void CetakDatamahasiswa(int N, TabMhs Mhs)
  46. {
  47. int j;
  48. std::cout << "NIM " << "Nama Mahasiswa " << " IPK" << std::endl;
  49. for (j=0; j<=N-1; j++)
  50. {a
  51. std::cout << Mhs[j].NIM << " " << Mhs[j].NamaMhs << " " <<Mhs[j].IPK << std::endl;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement