Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

C++ Program for Creating Student Objects with Exam and Result Functionalities, Assignments of Data Structures and Algorithms

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

2019/2020

Uploaded on 07/23/2020

mayank-raj-5
mayank-raj-5 🇮🇳

5 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
#include<iostream>
using namespace std;
class student
{
protected:
int roll_no;
char name[40];
char dept_name[40];
char college[40];
char dob[12];
public:
void get_input();
void print_data();
};
void student::get_input()
{
cout<<"\nEnter roll-no:";
cin>>roll_no;
cout<<"\nEnter name:";
cin.ignore();
cin.getline(name,100);
cout<<"\nEnter department name:";
cin.getline(dept_name,20);
cout<<"\nEnter college name:";
cin.getline(college,20);
cout<<"\nEnter date of birth of this student(in DD/MM/YY format):";
cin.getline(dob,12);
}
void student::print_data()
pf3
pf4
pf5

Partial preview of the text

Download C++ Program for Creating Student Objects with Exam and Result Functionalities and more Assignments Data Structures and Algorithms in PDF only on Docsity!

#include using namespace std; class student { protected: int roll_no; char name[40]; char dept_name[40]; char college[40]; char dob[12]; public: void get_input(); void print_data(); }; void student::get_input() { cout<<"\nEnter roll-no:"; cin>>roll_no; cout<<"\nEnter name:"; cin.ignore(); cin.getline(name,100); cout<<"\nEnter department name:"; cin.getline(dept_name,20); cout<<"\nEnter college name:"; cin.getline(college,20); cout<<"\nEnter date of birth of this student(in DD/MM/YY format):"; cin.getline(dob,12); } void student::print_data()

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; }