Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
30 views5 pages

Hjgjhguuijojoi

This code defines a structure to store student data including name, roll number, marks in 5 subjects, total, average and grade. It defines functions to calculate total, average and grade from the marks. It then takes input from the user for multiple students, calls the functions and stores the results in the structure array. It also finds the student with maximum marks in each subject.

Uploaded by

Manish Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views5 pages

Hjgjhguuijojoi

This code defines a structure to store student data including name, roll number, marks in 5 subjects, total, average and grade. It defines functions to calculate total, average and grade from the marks. It then takes input from the user for multiple students, calls the functions and stores the results in the structure array. It also finds the student with maximum marks in each subject.

Uploaded by

Manish Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CODE

#include<iostream.h>
#include<conio.h>
int n;
struct student{char name[20];
int rollno;
int marks[5];
int total;
int average;
char grade;
};
int calctotal(student s1)
{
int i,sum=0;
for(i=0;i<5;i++)

{
sum+=s1.marks[i];
}
return sum;
}
int calcavg(students1)
{
int avg=s1.total/5;
return avg;
}
char calcgrade(students1)
{
if(s1.total>400)
return'A';
else if(s1.total>300)
return'B';
else if(s1.total>200)
return 'C';
else if(s1.total>100)

return 'D';
elsereturn 'E';
}
int main()
{
clrscr();
students[20],tmp;
int
i,j,k,q,z,index[5],max[5]={0,0,0,0,0;
cout<<"Enter the number of
students:"<<endl;
cin>>n;
for(i=0;i<n;i++)
{

cout<<"Enter the details


ofstudent"<<i+1<<"\n";
cout<<"Name:";
cin>>s[i].name;
cout<<"Roll number:";
cin>>s[i].rollno;
cout<<"Marks:-
"<<endl;for(j=0;j<5;j++){cout<<"Subje
ct"<<j+1<<":";
cin>>s[i].marks[j];
}
s[i].total=calctotal(s[i]);
s[i].average=calcavg(s[i]);
s[i].grade=calcgrade(s[i]);
}
for(i=0;i<n;i++)
{
for(k=0;k<5;k++)
{
if(s[i].marks[k]>max[k])
{
max[k]=s[i].marks[k];
index[k]=i;
}
}
}

You might also like