adiee

Untitled

May 25th, 2021
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. Stat. 10) Write a C++ Program to display Names, Roll No.,
  2. and grades of 3 students who have appeared in the
  3. examinationn. Declare the class of name, Roll No.
  4. and grade. Create an array of class objects.Read
  5. and display the contents of the array.
  6.  
  7. Code :
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. class Student_Info{
  14. int roll_number;
  15. char student_name[50], grade[2];
  16.  
  17. public:
  18. void read_data(int count){
  19. cout<<"\n\n--------- Enter student "<<count+1<<" information ---------\n";
  20. cout<<"Name of the Student (Max. 50 characters only): ";
  21. cin>>student_name;
  22. cout<<"Roll Number: ";
  23. cin>>roll_number;
  24. cout<<"Grade (O, A+, A, B+, B, C, D, F): ";
  25. cin>>grade;
  26. cout<<"\nStudent information with roll number "<<roll_number<<" has saved!";
  27. }
  28. void display_data(int count){
  29. cout<<"\n\n******** Student "<<count+1<<" Information ********";
  30. cout<<"\nName of the Student: "<<student_name;
  31. cout<<"\nRoll Number: "<<roll_number;
  32. cout<<"\nGrade Secured: "<<grade;
  33. cout<<"\n---------------------------------------\n";
  34. }
  35. };
  36.  
  37. int main(){
  38. Student_Info stud[3];
  39. int i;
  40. for(i=0; i<3; i++)
  41. stud[i].read_data(i);
  42. cout<<"\n\n+++++++++++++++++++++++++++++++++++++++++++++++\n";
  43. cout<<"The information of 3 students has been saved.";
  44. cout<<"\n+++++++++++++++++++++++++++++++++++++++++++++++\n";
  45. for(i=0; i<3; i++)
  46. stud[i].display_data(i);
  47. return 0;
  48. }
  49.  
  50.  
  51. *****OUTPUT*****
  52.  
  53.  
  54. --------- Enter student 1 information ---------
  55. Name of the Student (Max. 50 characters only): Aditya
  56. Roll Number: 23
  57. Grade (O, A+, A, B+, B, C, D, F): O
  58.  
  59. Student information with roll number 23 has saved!
  60.  
  61. --------- Enter student 2 information ---------
  62. Name of the Student (Max. 50 characters only): Chaitrali
  63. Roll Number: 22
  64. Grade (O, A+, A, B+, B, C, D, F): A+
  65.  
  66. Student information with roll number 22 has saved!
  67.  
  68. --------- Enter student 3 information ---------
  69. Name of the Student (Max. 50 characters only): Yash
  70. Roll Number: 11
  71. Grade (O, A+, A, B+, B, C, D, F): A
  72.  
  73. Student information with roll number 11 has saved!
  74.  
  75. +++++++++++++++++++++++++++++++++++++++++++++++
  76. The information of 3 students has been saved.
  77. +++++++++++++++++++++++++++++++++++++++++++++++
  78.  
  79.  
  80. ******** Student 1 Information ********
  81. Name of the Student: Aditya
  82. Roll Number: 23
  83. Grade Secured: O
  84. ---------------------------------------
  85.  
  86.  
  87. ******** Student 2 Information ********
  88. Name of the Student: Chaitrali
  89. Roll Number: 22
  90. Grade Secured: A+
  91. ---------------------------------------
  92.  
  93.  
  94. ******** Student 3 Information ********
  95. Name of the Student: Yash
  96. Roll Number: 11
  97. Grade Secured: A
  98. ---------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment