OBJECT ORIENTED PROGRAMMING PROBLEM
OBJECT ORIENTED PROGRAMMING PROBLEM
#include<iostream>
using namespace std;
class student {
private:
char name[20];
int roll,mark1,mark2,mark3, total , percentage;
public:
void getdata(){
cout<<"Enter name of student : ";
cin>>name;
cout<<endl;
cout<<"Enter roll no of student : ";
cin>>roll;
cout<<endl;
cout<<"Enter Marks of subject 1 of student : ";
cin>>mark1;
cout<<endl;
cout<<"Enter Marks of subject 2 of student : ";
cin>>mark2;
cout<<endl;
cout<<"Enter Marks of subject 3 of student : ";
cin>>mark3;
cout<<endl;
}
void calculate();
void display(){
cout<<"The name of student is "<<name;
cout<<endl;
cout<<"The roll of student is "<<roll;
cout<<endl;
cout<<"The mark1 of student is "<< mark1;
cout<<endl;
cout<<"The mark2 of student is "<<mark2;
cout<<endl;
cout<<"The mark2 of student is "<<mark2;
cout<<endl;
cout<<"The total marks of student is "<<total;
cout<<endl;
cout<<"The percentage of student is "<<percentage;
cout<<endl;
}
};
void student :: calculate(){
total = mark1 + mark2 + mark3;
percentage = total/3;
}
int main(){
student Gaurav;
Gaurav.getdata();
Gaurav.calculate();
Gaurav.display();
}
Comments
Post a Comment