fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Student
  5. {
  6. int id;
  7. float cgpa;
  8. };
  9.  
  10. int main() {
  11. Student s[3];
  12.  
  13. for (int i = 0; i < 3; i++)
  14. {
  15. cout << "Enter ID and CGPA for student " << i + 1 << ": " <<endl;;
  16. cin >> s[i].id >> s[i].cgpa;
  17. }
  18. // Display data
  19. for (int i = 0; i < 3; i++)
  20. {
  21. cout << "Student " << i + 1
  22. << " | ID: " << s[i].id
  23. << " | CGPA: " << s[i].cgpa << endl;
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5320KB
stdin
1
stdout
Enter ID and CGPA for student 1: 
Enter ID and CGPA for student 2: 
Enter ID and CGPA for student 3: 
Student 1 | ID: 1 | CGPA: 0
Student 2 | ID: 2 | CGPA: 0
Student 3 | ID: 1643232024 | CGPA: 4.59135e-41