0% found this document useful (0 votes)
14 views

Cs Assignment

The document defines classes for student, marks, and result to store and process student data. It defines methods to read student data, get marks, calculate totals and percentages, and output results. The main function demonstrates using the classes to get input, process marks, and output a student's result.

Uploaded by

Shruti Surlakar
Copyright
© © All Rights Reserved
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)
14 views

Cs Assignment

The document defines classes for student, marks, and result to store and process student data. It defines methods to read student data, get marks, calculate totals and percentages, and output results. The main function demonstrates using the classes to get input, process marks, and output a student's result.

Uploaded by

Shruti Surlakar
Copyright
© © All Rights Reserved
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/ 4

#include<iostream>

using namespace std;


class student
{
Private:
int r;
char name[20];
public:
void read();
void display();

};
class marks:public student
{
protected:
int s1;
int s2;
int s3;
public:
void getmarks();
void putmarks();
};
class result: public marks
{
private:
int t;
float p;
public:
int process();
int printresult();
int process2();
};
void student::read()
{
cout<<"Enter Roll no. : ";
cin>>r;
cout<<"Enter Name : ";
cin>>name;
}
void student::display()
{
cout<<”********************”;
cout<<”RESULT”;
cout<<”********************”;

cout <<"\nRoll no. : "<<r<<endl;


cout<<"Name : "<<name<<endl;
cout<<"\n";
}
void marks::getmarks()
{
cout<<"Enter marks out of 10 for 3 subjects : "<<endl;
cout<<"PHYSICS";
cin>>s1;
cout<<"CHEMISTRY";
cin>>s2;
cout<<"MATHS";
cin>>s3;
}
void marks::putmarks()
{
cout<<"PHYSICS:"<<s1<<endl;
cout<<"CHEMISTRY : "<<s2<<endl;
cout<<"MATHS : "<<s3<<endl;
}
int result::process()
{
t= s1+s2+s3;
p = t/3;
}
int result::printresult()
{
cout<<"Total = "<<t<<endl;
cout<<"\n";
cout<<"Percentage = "<< p<<endl;
}
int result ::process2()
{
if(p>75)
cout<<"pass"<<endl;
else
cout<<"fail"<<endl;
}
int main()
{
result x;
x.read();
x.getmarks();
x.process();
x.display();
x.putmarks();
x.process2();
x.printresult();
return 0;

You might also like