Answer:
#include<iostream>
#include<conio.h>
using namespace std;
struct studentdata{
char Fname[50];
char Lname[50];
int marks;
char grade;
};
main()
{
studentdata s[20];
for (int i=0; i<20;i++)
{
cout<<"\nenter the First name of student";
cin>>s[i].Fname;
cout<<"\nenter the Last name of student";
cin>>s[i].Lname;
cout<<"\nenter the marks of student";
cin>>s[i].marks;
}
for (int j=0;j<20;j++)
{
if (s[j].marks>90)
{
s[j].grade ='A';
}
else if (s[j].marks>75 && s[j].marks<90)
{
s[j].grade ='B';
}
else if (s[j].marks>60 && s[j].marks<75)
{
s[j].grade ='C';
}
else
{
s[j].grade ='F';
}
}
int highest=0;
int z=0;
for (int k=0;k<20; k++)
{
if (highest<s[k].marks)
{
highest = s[k].marks;
z=k;
}
}
cout<<"\nStudents having highest marks"<<endl;
cout<<"Student Name"<< s[z].Fname<<s[z].Lname<<endl;
cout<<"Marks"<<s[z].marks<<endl;
cout<<"Grade"<<s[z].grade;
getch();
}
Explanation:
This program is used to enter the information of 20 students that includes, their first name, last name and marks obtained out of 100.
The program will compute the grades of the students that may be A,B, C, and F. If marks are greater than 90, grade is A, If marks are greater than 75 and less than 90, grade is B. For Mark from 60 to 75 the grade is C and below 60 grade is F.
The program will further found the highest marks and than display the First name, last name, marks and grade of student who have highest marks.