Wednesday, 2 March 2016

Q. Calculate 3 subject marks ?

THE OUTPUT WOULD BE














#include<iostream.h>
#include<conio.h>
class A
{ float p,c,m,n,t;
char s[20];
public:
void B();
void C();
};
void A::B()
{ cout<<"Enter your name:";
cin>>s;
cout<<"Enter your roll number:";
cin>>n;
}
void A::C()
{       cout<<"Enter your subjectes marks out of 100\n";
cout<<"Enter your Physics marks:";
cin>>p;
cout<<"Enter your Chemistry marks:";
cin>>c;
cout<<"Enter your Mathematics marks:";
cin>>m;
t=(p+m+c)/3;
cout.precision(2);
cout<<"Your percentage is "<<t<<"%";
}
void main()
{ clrscr();
A obj;
obj.B();
obj.C();
getch();
}

No comments:

Post a Comment