Based on the function main( ) on the left, complete the calling function double
ID: 3588268 • Letter: B
Question
Based on the function main( ) on the left, complete the calling function double InputYearOfDataAndReturnAverage( ) on the right (lines 13-19) to successfully compute the average rainfall for each year.The input is a year followed by 12 real numbers which stand for the amount of rainfall for the 12 months of January through December. The last line of input is -1 to end the while loop. Ex: 2011 .71 3.46 2.32 5.73 5.32 7.41 5.44 3.94 3.89 2.24 3.65 2.51 -1 this will give an output of 2011: 3.885 1 nain.cpp 1 Panalysis.cpp*
Explanation / Answer
**CODE of the function:
double InputYearOfDataAndReturnAverage(){
double sum = 0, rainfall_value;
for(int i = 0; i < 12; i++){
cin >> rainfall_value;
sum += rainfall_value;
}
return sum / 12;
}
**Comment for any further queries. Upvote if the answer is satisfactory.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.