Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Stat. 10) Write a C++ Program to display Names, Roll No.,
- and grades of 3 students who have appeared in the
- examinationn. Declare the class of name, Roll No.
- and grade. Create an array of class objects.Read
- and display the contents of the array.
- Code :
- #include <iostream>
- using namespace std;
- class Student_Info{
- int roll_number;
- char student_name[50], grade[2];
- public:
- void read_data(int count){
- cout<<"\n\n--------- Enter student "<<count+1<<" information ---------\n";
- cout<<"Name of the Student (Max. 50 characters only): ";
- cin>>student_name;
- cout<<"Roll Number: ";
- cin>>roll_number;
- cout<<"Grade (O, A+, A, B+, B, C, D, F): ";
- cin>>grade;
- cout<<"\nStudent information with roll number "<<roll_number<<" has saved!";
- }
- void display_data(int count){
- cout<<"\n\n******** Student "<<count+1<<" Information ********";
- cout<<"\nName of the Student: "<<student_name;
- cout<<"\nRoll Number: "<<roll_number;
- cout<<"\nGrade Secured: "<<grade;
- cout<<"\n---------------------------------------\n";
- }
- };
- int main(){
- Student_Info stud[3];
- int i;
- for(i=0; i<3; i++)
- stud[i].read_data(i);
- cout<<"\n\n+++++++++++++++++++++++++++++++++++++++++++++++\n";
- cout<<"The information of 3 students has been saved.";
- cout<<"\n+++++++++++++++++++++++++++++++++++++++++++++++\n";
- for(i=0; i<3; i++)
- stud[i].display_data(i);
- return 0;
- }
- *****OUTPUT*****
- --------- Enter student 1 information ---------
- Name of the Student (Max. 50 characters only): Aditya
- Roll Number: 23
- Grade (O, A+, A, B+, B, C, D, F): O
- Student information with roll number 23 has saved!
- --------- Enter student 2 information ---------
- Name of the Student (Max. 50 characters only): Chaitrali
- Roll Number: 22
- Grade (O, A+, A, B+, B, C, D, F): A+
- Student information with roll number 22 has saved!
- --------- Enter student 3 information ---------
- Name of the Student (Max. 50 characters only): Yash
- Roll Number: 11
- Grade (O, A+, A, B+, B, C, D, F): A
- Student information with roll number 11 has saved!
- +++++++++++++++++++++++++++++++++++++++++++++++
- The information of 3 students has been saved.
- +++++++++++++++++++++++++++++++++++++++++++++++
- ******** Student 1 Information ********
- Name of the Student: Aditya
- Roll Number: 23
- Grade Secured: O
- ---------------------------------------
- ******** Student 2 Information ********
- Name of the Student: Chaitrali
- Roll Number: 22
- Grade Secured: A+
- ---------------------------------------
- ******** Student 3 Information ********
- Name of the Student: Yash
- Roll Number: 11
- Grade Secured: A
- ---------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment