Respuesta :
Answer:
#include <stdio.h>
int p;
int g(int n)
{
static int minimum=101, maximum=-1, average=0;
if(n==0)
return -1;
else
{
printf("Enter course grade %d: ",p-n+1);
int grade;
scanf("%d",&grade);
g(n-1);
printf("%d\n",grade);
if(minimum>grade)
minimum=grade;
if(maximum<grade)
maximum=grade;
average=average+grade;
if(n==p)
{
printf("minimum= %d\n",minimum);
printf("maximum= %d\n",maximum);
printf("Average= %.2f\n",(double)average/(double)n);
}
return -1;
}
}
int main()
{
printf("Enter the number of grades:\n");
scanf("%d",&p);
g(p);
return 0;
}
Explanation:
- Use a conditional statement to check to find the maximum and minimum grade.
- Check if n is equal to p, then display the values of maximum and minimum.
- Calculate the average by dividing the sum with the total numbers and then display its value.
- Inside the main function, get number of grades from user as an input.
- Lastly, call the function g and pass it the value of grade.