class student
{ private:
int roll;
char name[20];
float percentage;
char result[5];
void calc_result();
public:
void indata();
void outdata();
};
void student :: indata()
{ cin>> roll;
gets(name);
cin>> percentage;
calc_result();
}
void student :: outdata()
{ cout<< roll<<name<< percentage<< result;}
void student :: calc_result()
{ if (percentage> 50)
strcpy(result, “PASS”);
else
strcpy(result, “FAIL”);
}
void main()
{
student stu[10];
for(int i=0; i<10; i++)
stu[i].indata();
for(int i=0; i<10; i++)
stu[i].outdata();
}
No comments:
Post a Comment