Answer to Question #202425 in C++ for Jordaine Myrie

Question #202425

Write a function, called calcAvgTemp, that accepts TWO (2) arguments in its parameter: a floating-point array, and a value representing the size for the floating-point array. Your solution must calculate the average of the values found in the array, and then return the result as a floating-point value. 


1
Expert's answer
2021-06-05T23:51:10-0400
 
#include <iostream>


using namespace std;
float calcAvgTemp(float arr[],int size){
    float sum=0;
    for(int i=0;i<size;i++){
        sum=sum+arr[i];
    }
    float average=sum/size;
    return average;
}
int main()
{
    float arr2[10]={20.7,30.4,40.2,13.3,45.9,34.7,56.6,78.3,54.4,23.6};
    cout<<"\nAverage: "<<calcAvgTemp(arr2,10);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog