On the back of the page, write a syntactically correct C function find_highest-g
ID: 3701113 • Letter: O
Question
On the back of the page, write a syntactically correct C function find_highest-grade which takes an array of Student objects (along with the number of elements of that array) and returns the nm value of the grade component in an element of the array. Your code is expected to work on all valid arrays (of size at least 1), not just the example below Code Output #include typedef struct char student id[10]; int grade; Student; /* The code for your answer would be placed here / int main)( Student CSCI 11Students [4] = { Highest grade: 83 ("V00123456",68, f"V00999999",71, ("V00987654" ,83, ("V00111222",65 int highest = find-highest-grade(CSC1 11students, printf ("Highest grade : %d ", highest); return 0; 4);Explanation / Answer
#include <stdio.h>
struct studentInfo
{
char name[50];
int marks;
};
int main()
{
int i;
int n;
int maxGrade=0;
printf("Enter number of information of students you want to store : ");
scanf("%d",&n);
if(n<1)
printf("Enter number of information of students at least 1 : ");
struct studentInfo s[n];
// storing information
for(i=0; i<n; ++i)
{
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter grade: ");
scanf("%d",&s[i].marks);
printf(" ");
}
printf("Displaying All Students Information: ");
// displaying Students information
for(i=0; i<n; ++i)
{
printf("Student Name: ");
puts(s[i].name);
printf("Student Marks: %d",s[i].marks);
printf(" ");
}
printf(" Highest grade :");
//finding Highest grade
for(i=0; i<n; ++i)
{
if(maxGrade>s[i].marks){}
else
maxGrade=s[i].marks;
}
printf("%d",maxGrade);
return 0;
}
Thanks ,Please give your valuable comment.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.