Pages

Monday, October 10, 2011

FUNCTIONS_2

WAP TO ENTER NUMBER OF STUDENTS AS PER USER CHOICE AND INPUT MARKS IN SUBJECTS AND DISPLAY



#include<iostream.h>
#include<conio.h>
class student
{
int rno;
char name[30];
float eng,math,sci,tot;
public:
void init();
void caltot();
void display();
};
void student::init()
{
cout<<"Enter rno,name,eng,math & science marks::";
cin>>rno>>name>>eng>>math>>sci;
}
void student::caltot()
{
tot=sci+math+eng;
}
void student::display()
{
cout<<"Rno::"<<rno<<endl
    <<"Name::"<<name<<endl
    <<"Science::"<<sci<<endl
    <<"Math::"<<math<<endl
    <<"English::"<<eng<<endl
    <<"total::"<<tot<<endl;

}
void main()
{
clrscr();
int i,n;
cin>>n;
student s[4];
for(i=0;i<n;i++)
{
s[i].init();
s[i].caltot();
s[i].display();
}
getch();
}

No comments: