#include<iostream.h>
#include<conio.h>
#include<string.h>
class student
{
int rno;
char name[20];
int no_of_sub;
int *m;
char grade[30];
public:
student(){}
student(int x,char *s,int n);
void display(void);
};
student::student(int x,char *s,int n)
{
rno=x;
strcpy(name,s);
no_of_sub=n;
m=new int[no_of_sub];
cout<<"\n\nEnter the marks of "<<no_of_sub<<" subjects";
for(int i=0;i<no_of_sub;i++)
cin>>m[i];
}
void student::display(void)
{
float per,sum=0;
cout<<"\n\nStudent Roll No. : "<<rno;
cout<<"\n\nStudent Name : "<<name;
cout<<"\n\nNumber of subjects : ";
cout<<no_of_sub;
cout<<"\n\nMarks of subjects : ";
for(int i=0;i<no_of_sub;i++)
{
cout<<m[i]<<"\t";
}
for( i=0;i<no_of_sub;i++)
{
sum=sum+m[i];
}
per=sum/no_of_sub;
cout<<"\n\nPercentage of student : "<<per;
if(per>=75)
strcpy(grade,"Distinction");
else if(per<75 &&per>=60)
strcpy(grade,"First Class");
else if(per<60 && per>=50)
strcpy(grade,"Second Class");
else if(per<50 && per>=40)
strcpy(grade,"Pass");
else
strcpy(grade,"Fail");
cout<<"\n\nClass obtained : "<<grade;

}
int main()
{
clrscr();
int n;
student S[3];
cout<<"\n\nEnter how many records you want to enter : ";
cin>>n;
int r_no;
char nm[20];
int nos;
for(int i=0;i<n;i++)
{
cout<<"\n\nEnter Student Roll No. : ";
cin>>r_no;
cout<<"\n\nEnter Student Name : ";
cin>>nm;
cout<<"\n\nEnter Number of subjects : ";
cin>>nos;
student A(r_no,nm,nos);
S[i]=A;
}
for(i=0;i<n;i++)
{
S[i].display();
}
getch();
return(0);
}

Post a Comment

Previous Post Next Post