This is the problem I\'m having trouble with... Write a program to calculate the
ID: 3534916 • Letter: T
Question
This is the problem I'm having trouble with...
Write a program to calculate the average of a series of test scores, where the lowest score in the series is dropped. The program must use the following function types:
Void getValues();
void calcAvg (int, int, int, int, int);
int findLow (int, int, int, int, int);
The insistence that we use value parameters with these function prototypes restricts the way we write the program. For example, to input the test scores, call the function getValues() from the funcion main(). Since getValues() is a void function, then nothing is returned to main(). The remaining logic flow must be completed with function calls from the function getValues() as you see fit.
Write the program code to handle as many as 40 test scores; however, for this assignment you will enter only the following five scores: 70, 80, 60, 80, 70
Explanation / Answer
#include<iostream.h>
Void getValues();
void calcAvg (int, int);
int findLow (int, int);
int a[40],n;
void main()
{
getvalues();
valcavg(a[],n);
l=findlow(a[],n);
cou<<"Lowest value is "<<l;
}
void getvalues()
{
cout<<"enter values the number data u want to enter";
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
}
void calcavg(int a[], int n)
{
int tot=0;
float avg;
for(int i=0;i<n;i++)
tot=tot+a[i];
avg=tot/n;
cout<<"average is "<<avg;
}
int findlow(int a[],int n)
{
int l=a[0];
for(int i=0;i<n;i++)
{
if(a[i}<l)
l=a[i];
}
return l;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.