write a complete program which initializes part of an array of integer grades at the time of its declaration with 6 values and then calls a function to find, return, and print the highest grade.
Solution
Grades.c
#include <stdio.h>
int find(int grades[]);
int main()
{
int grades[6];
for(int i=0; i<6; i++){
printf(\"Enter Integer Grade : \ \");
scanf(\"%d\", &grades[i]);
}
int maxGrade = find(grades);
printf(\"The Maximum Grade is %d \",maxGrade);
return 0;
}
int find(int grades[]){
int max = 0;
for(int i=0; i<6; i++){
if(max < grades[i])
max = grades[i];
}
return max;
}
Output:
Enter Integer Grade :
87
Enter Integer Grade :
65
Enter Integer Grade :
45
Enter Integer Grade :
34
Enter Integer Grade :
87
Enter Integer Grade :
56
The Maximum Grade is 87
.