// Program 4.7.1 #include using namespace std; double getAverage(int *arr, int size); // function declaration: int main () { int balance[5] = {12, 34, 56, 78, 91}; // an int array with 5 elements....



// Program 4.7.1




#include
using namespace std;
double getAverage(int *arr, int size); // function declaration:
int main ()
{
int balance[5] = {12, 34, 56, 78, 91}; // an int array with 5 elements.
double avg;
avg = getAverage( balance, 5 ) ; // pass pointer to the array as an argument.
cout < "average="" value="" is:="" "="">< avg="">< endl;="" output="" the="" returned="">
return 0;
}
double getAverage(int *ARRAY1, int size)
{
int i, sum = 0;
double avg;
for (i = 0; i < size;="">
 {
 sum += ARRAY1[i];
 }
avg = double(sum) / size;
return avg;
}



TASK



1. Explain in details what the program does?



2. What is the output


4.7 Pointer 3<br>|// Program 4.7.1<br>#include <iostream><br>using namespace std;<br>double getAverage(int *arr, int size);<br>int main ()<br>// function declaration:<br>// an int array with 5 elements.<br>int balance[5] = {12, 34, 56, 78, 91};<br>double avg;<br>avg = getAverage( balance, 5 );<br>cout «

Extracted text: 4.7 Pointer 3 |// Program 4.7.1 #include using namespace std; double getAverage(int *arr, int size); int main () // function declaration: // an int array with 5 elements. int balance[5] = {12, 34, 56, 78, 91}; double avg; avg = getAverage( balance, 5 ); cout « "Average value is: "< avg=""><« endl;="" output="" the="" returned="" value="" pass="" pointer="" to="" the="" array="" as="" an="" argument.="" return="" 0;="" }="" double="" getaverage(int="" "array1,="" int="" size)="" int="" i,="" sum="0;" double="" avg;="" for="" (i="0;" i="">< size;="" +ti)="" sum="" +="ARRAY1[i);" avg="double(sum)" size;="" return="">

Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here