# Geeksforgeeks Solution For " Student record "

GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers

Problem :- A file contains data as follows( Student name, marks in 3 subjects)
Shrikanth 20 50 60
Kiran 30 80 90
Find the student who has maximum average score.

Solution :-

Method 1 :- For Submitting in Geeks for geeks

#include <iostream>
using namespace std;

int main()
{
int t,n,s1,s2,s3,avg;
string s,r;
cin>>t;
while(t--)
{
cin>>n;
cin>>s>>s1>>s2>>s3;
r=s;
avg=(s1+s2+s3)/3;
n=n-1;
while(n--)
{
cin>>s>>s1>>s2>>s3;
if(((s1+s2+s3)/3)>avg)
{
avg=(s1+s2+s3)/3;
r=s;
}
}
cout<<r<<" "<<avg<<"\n";

}
return 0;
}

Method 2 :-

#include <iostream>
using namespace std;
struct student
{
string name;
int m1,m2,m3;
};

int main()
{
int t;
cin>>t;
while(t--)
{
int n,i,sum=0;
cin>>n;
struct student s[n];
string ch;
for(i=0;i<n;i++)
{
cin>>s[i].name>>s[i].m1>>s[i].m2>>s[i].m3;
}
sum=(s[0].m1+s[0].m2+s[0].m3)/3;
for(i=1;i<n;i++)
{
if((s[i].m1+s[i].m2+s[i].m3)>sum)
{
sum=(s[i].m1+s[i].m2+s[i].m3)/3;
ch=s[i].name;
}
}
cout<<ch<<" "<<sum;
cout<<"\n";
}
return 0;
}

Output:-

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.