0% found this document useful (0 votes)
44 views2 pages

Class Protected Int Public Void Int: #Include #Include

The document defines several C++ classes to store and output student result data. The result class inherits from the test and sports classes to access exam marks and sports score data, respectively. An object of the result class is created in main, data is inputted, and the display method outputs the roll number, individual marks, sports score, and total score.

Uploaded by

anju9850
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Class Protected Int Public Void Int: #Include #Include

The document defines several C++ classes to store and output student result data. The result class inherits from the test and sports classes to access exam marks and sports score data, respectively. An object of the result class is created in main, data is inputted, and the display method outputs the roll number, individual marks, sports score, and total score.

Uploaded by

anju9850
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream.h> #include<conio.

h> class stu { protected: int rno; public: void get_no(int a) { rno=a; } void put_no(void) { out<<"Roll no"<<rno<<"\n"; } }; class test:public stu { protected: float part1,part2; public: void get_mark(float x,float y) { part1=x; part2=y; } void put_marks() { cout<<"Marks obtained:"<<"part1="<<part1<<"\n"<<"part2="<<part2<<"\n"; } }; class sports { protected: float score; public: void getscore(float s) { score=s; } void putscore(void) { cout<<"sports:"<<score<<"\n"; } }; class result: public test, public sports { float total; public: void display(void); }; void result::display(void) { total=part1+part2+score; put_no(); put_marks(); putscore(); cout<<"Total Score="<<total<<"\n"; }

int main() { clrscr(); result stu; stu.get_no(123); stu.get_mark(27.5,33.0); stu.getscore(6.0); stu.display(); return 0; } OUTPUT Roll Marks Part2=33 Sports=6 Total score = 66.5 no obtained : 123 part1=27.5

You might also like