C++ Programming Blog

 
 
 
#include<iostream.h>
#include<conio.h>
class data
{
    int rollno,maths,science;
    int avg();
    public:
        void getdata();
        void putdata();
};

main()
{
    clrscr();
    data stud[5];
    for(int i=0;i<5;i++)
        stud[i].getdata();
}

void data::getdata()
{
    cout<<\"Please enter rollno:\";
    cin>>rollno;
    cout<<\"Please enter maths marks:\";
    cin>>maths;
    cout<<\"Please enter science marks:\";
    cin>>science;
    putdata();
}

int data::avg()
{
    int a;
    a=(maths+science)/2;
    return a;
}

void data::putdata()
{
    cout<<\"Average is :\"<<avg()<<endl;
}