Question #31598

2. "Write a function for finding out highest and lowest marks obtained by a student from an array contained student name and marks".
For Example :
GetHighestLowestMarks{Student{n}, Marks{n}} returns an arraycontain student name and marks.

Expert's answer

#include <iostream>

using namespace std;

int fun()

{

& int a[10];

& cout<<"enter student name"<<endl;

& char r[10];

& cin>>r;

& cout<<"enter 10 student marks"<<endl;

for(int i=0;i<10;i++){

cin>>a[i];

}

& int max=0;

& int min;

& for(int j=0;j<10;j++)

& {

if (min>a[j]) {min=a[j];}

if (max<a[j]) {max=a[j];}

& }

& cout<<endl<<r<<endl<<"min= "<<min<<endl<<"max= "<<max<<endl;

}

int main()

{

fun();

return 0;

}

using namespace std;

int fun()

{

& int a[10];

& cout<<"enter student name"<<endl;

& char r[10];

& cin>>r;

& cout<<"enter 10 student marks"<<endl;

for(int i=0;i<10;i++){

cin>>a[i];

}

& int max=0;

& int min;

& for(int j=0;j<10;j++)

& {

if (min>a[j]) {min=a[j];}

if (max<a[j]) {max=a[j];}

& }

& cout<<endl<<r<<endl<<"min= "<<min<<endl<<"max= "<<max<<endl;

}

int main()

{

fun();

return 0;

}

## Comments

## Leave a comment