Lowest Score Drop Write a program that calculates the average of a group of test
ID: 3694536 • Letter: L
Question
Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: Void getScore() should ask the user for a test score, store it in a reference parame- ter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores. int findLowest() should find and return the lowest of the five scores passed to it It should be called by calcAverage, which uses the function to determine one of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100.Explanation / Answer
#include<stdio.h>
#include<conio.h>
void main()
{
int score;
int &s=score;
int i,j;
int sum=0;
int grades[5];
void getScore(int );
void calcAverage(int );
clrscr();
i=0;
j=0;
while(i<5)
{
printf(" enter a value...");
scanf("%d",&score);
if(s>0 && s<=100)
{
i++;
grades[j++]=s;
getScore(s);
}
sum=sum+s;
}
for(j=0;j<5;j++)
printf(" %d",grades[j]);
calcAverage(&grades[0]);
getch();
}
void getScore(int scr)
{
static int i=0;
int ar[5];
ar[i]=scr;
i++;
}
void calcAverage(int *val)
{
int i;
int sum=0;
float avg=0;
for(i=0;i<5;i++)
sum=sum+(*(val+i));
sum=sum-findLowest(val);
avg=avg/4;
printf(" avg of four highest numbers are %f",avg)
}
int findLowest(int *v)
{
int num;
int small;
int temp;
int i;
small=*v;
for(i=0;i<5;i++)
{
if(small<*(v+i))
{
temp=small;
small=*(v+i);
*(v+i)=temp;
}
}
return small;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.