Saturday, March 19, 2011

Program for Constructors Using OOPs & C++ concept


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


class Student
{
private:
int Sub1,Sub2,Sub3,Total;
float avg;
public:
Student()                      //Default Constructor
{
cout<<"Enter the Marks For Three Subjects";
cin>>Sub1>>Sub2>>Sub3;
Total=Sub1+Sub2+Sub3;
avg=Total/3;
}
void put()
{
cout<<"Total Marks Of Student is"<<Total<<endl;
Cout<<"Avg Marks Of Student is"<<avg<<endl;
}
~Student()
{};
};
void main()
{
Student s;
s.put();
getche();
}

No comments:

Post a Comment