#include<iostream>
#include<string.h>
using namespace std;
//#include<conio.h>
int tot=0,j;
float avg;
class student
{
int rollno,subjects;
char stud_name[20];
int *marks;
public:
student(int rno,char *name,int sub)
{
rollno=rno;
strcpy(stud_name,name);
subjects=sub;
marks=new int[subjects];
}
void getdata();
void grade();
void putdata();
};
void student::getdata()
{
for(int i=0;i<subjects;i++)
{
cout<<"\n Enter mark for subject "<<i+1<<" : ";
cin>>marks[i];
tot+=marks[i];
}
avg=tot/subjects;
}
void student::grade()
{
if(avg>=91 && avg<=100)
cout<<"\n Grade is : 'A+'";
else if(avg>=81 && avg<=90)
cout<<"\n Grade is : 'A'";
else if(avg>=71 && avg<=80)
cout<<"\n Grade is : 'B'";
else if(avg>=51 && avg<=70)
cout<<"\n Grade is : 'C'";
else
cout<<"\n Grade is : 'D'";
}
void student::putdata()
{
cout<<"\n Student Information.";
cout<<"\n---------------------------------";
cout<<"\n Student Rollno : "<<rollno;
cout<<"\n Student Name : "<<stud_name;
for(int i=0;i<subjects;i++)
{
cout<<"\n Marks of Subject "<<i+1<<" : "<<marks[i];
}
cout<<"\n\n Total : "<<tot;
cout<<"\n Average : "<<avg;
}
int main()
{
int rollno,subjects;
char stud_name[20];
int cnt,i;
//clrscr();
cout<<"\n---------------------------------";
cout<<"\n Student Mark List";
cout<<"\n---------------------------------";
cout<<"\n Enter the no.of students you want? : ";
cin>>cnt;
for(i=0;i<cnt;i++)
{
cout<<"\n---------------------------------";
cout<<"\n Enter the Student Rollno : ";
cin>>rollno;
cout<<"\n Enter the Student Name : ";
cin>>stud_name;
cout<<"\n Enter the no.of Subjects : ";
cin>>subjects;
cout<<"\n---------------------------------";
student stu(rollno,stud_name,subjects);
stu.getdata();
cout<<"\n---------------------------------";
stu.putdata();
stu.grade();
cout<<"\n---------------------------------";
}
//getch();
return(0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: