![orladuffy1](/avatars/49435.jpg)
orladuffy1
16.03.2020 •
Computers and Technology
Write a C program to calculate the minimum, maximum, and average of n grades entered by the user. The program uses a function int g(int n) to calculate the requirements above and also prints the grades in reverse order. The function should utilize the concepts of recursion and static storage class specifier.
Solved
Show answers
More tips
- A Auto and Moto What to expect from the new VW Golf 7?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- S Style and Beauty How to Get Rid of Peeling Nails: Natural Remedies...
- S Science and Technology Understanding Magnetic Storms: A Guide to This Natural Phenomenon...
- F Family and Home What is Most Important in Men s Lives?...
- G Goods and services Which TV is better - LCD or Plasma?...
- C Computers and Internet Are there special gaming mice?...
- G Goods and services LED-подсветка в LCD-телевизорах: 5 причин, почему она лучше других технологий...
- C Computers and Internet Keep Your Mouse Pad Clean: The Right Way to Clean It?...
Answers on questions: Computers and Technology
- H History How did the cotton gin impact the backcountry in south carolina?...
- B Biology What is the process by which internal environments of an organism are regulated....
- C Chemistry In which of the following conditions would a person not hear an echo? a. a sound wave reaches the ear,and the reflected wave reaches the ear less than 0.1 seconds later....
- M Mathematics 2. A couple chooses to rent their investment property on Sanibel Island through Verbo. The cost of renting the condo includes a $175 cleaning fee plus the cost of $299...
- E English 3. Page 108: Does Kuper do an effective job of depicting Gregor’s room as “a proper human room” that “lays peacefully between its four familiar walls”? Use details from...
Ответ:
#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.Ответ:
The latest PCIe ×16 primary slot top near to CPU should be the answer to this question.