This program requires four additional functions to be implemented. You must impl
ID: 674038 • Letter: T
Question
This program requires four additional functions to be implemented. You must implement the function to determine the highest value in the array, and the function to determine the lowest value in the array. You can name these functions whatever you want to ( I suggest findHighValue and findLowValue). They need to be declared with a prototype above main and defined below (examine all of the source code and comments). You must also implement a programmer info function, that outputs the required info.
The last function to implement is the function to calculate the standard deviation. The algorithm to accomplish this is provided for you in one of the examples. You must copy these algorithm steps into your solution (put them in the function to explain the steps taken to accomplish the calculation). If you have trouble implementing the function, you can refer to graphic 8-1 on the next page as a reference.
Explanation / Answer
#include <stdio.h>
int findHighValue(int[],int);
int findLowValue(int[],int);
double stdDeviation(int[],int);
int main(){
int a[]={4,1,28,19,320,32};
int high=findHighValue(a,6);
int low=findLowValue(a,6);
double sd=stdDeviation(a,6);
printf("Maximum= %d ",high);
printf("Minimum= %d ",low);
printf("Standard Deviation= %.2f ",sd);
return 0;
}
int findHighValue(int a[],int n){
int i,max=a[n-1];
for(i=0;i<n;i++){
if(max<a[i]){
max=a[i];
}
}
return max;
}
int findLowValue(int a[],int n){
int i,min=a[n-1];
for(i=0;i<n;i++){
if(min>a[i]){
min=a[i];
}
}
return min;
}
double stdDeviation(int a[],int n){
double mean=0.0, sum_deviation=0.0;
int i;
for(i=0; i<n;++i)
{
mean+=a[i];
}
mean=mean/n;
for(i=0; i<n;++i)
sum_deviation+=(a[i]-mean)*(a[i]-mean);
return sqrt(sum_deviation/n);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.