



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This C++ program includes a student class with details like roll number, name, department name, college name, and date of birth. The exam class is inherited from student and includes an array to store marks obtained in six subjects. The result class is inherited from exam and calculates the grand total of marks. The program takes input of the number of students, creates student objects, and displays their details and marks obtained.
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!
#include
cout<<"\n\nRoll:"<<roll_no; cout<<"\n\nName:"<<name; cout<<"\n\nDate of birth:"<<dob; cout<<"\n\nDepartment:"<<dept_name; cout<<"\n\nCollege:"<<college; } class exam:virtual public student { protected: int marks[5]; public: void get_marks(); void print_marks(); }; void exam::get_marks() { cout<<"\nEnter Marks\n-------------------\n"; for(int i=0;i<6;i++) { while(true) { cout<<"\nSubject"<<i+1<<":"; cin>>marks[i]; if(marks[i]>=0&&marks[i]<=100) break; cout<<"Invalid marks given!!Enter proper marks..\n"; } }
int main() { int num,i; while(true) { cout<<"Enter number of students:"; cin>>num; if(num>0) break; cout<<"Invalid number given!!\n"; } result *stu=new result[num]; for(i=0;i<num;i++) { cout<<"\n\nEnter record for student no:"<<i+1<<"\n\n-------------------------
n-------------------------"; stu[i].get_info(); } cout<<"\n\nDisplaying results of students \n--------------------------------------------------------\n"; for(i=0;i<num;i++) { cout<<"\n\n\nRecord for student no:"<<i+1<<"\n\n------------------------\n------------------------"; stu[i].display(); } cout<<"\n"; delete[]stu; return 0; }