Does the size of the parameter arr[] (which is a pointer to an array) matter? I know arr[] is treated as a pointer, does it matter if you put a value in between those brackets? If so why? If not why?
Why is arr[] treated as a pointer? Can it be re-written as int *arr (with no brackets)?
I know the parameter size can take any value, but what about the pointer (int arr[]) pointing to an array?
#include <iostream>
using namespace std;
// function declaration:
double getAverage(int arr[], int size);
int main () {
// an int array with 5 elements.
int balance[5] = {1000, 2, 3, 17, 50};
double avg;
// pass pointer to the array as an argument.
avg = getAverage( balance, 5 ) ;
// output the returned value
cout << "Average value is: " << avg << endl;
return 0;
}