size of array - why function gives size ONE only
the user-defined function size_of_array(numA) is meant to give the size of numA which is 5 but it gives 1... I wonder where went wrong? can anyone help pls...
insert
Code:
#include <iostream>
using namespace std;
int size_of_array(int numA[]);
int main()
{
int numA[]={0,1,2,3,4};
int i=0;
int total=0;
for(i=0; i<size_of_array(numA); i++)
{
total+=numA[i];
}
float average=total/i;
cout << "average is "<<average;
return 0;
}
int size_of_array(int numA[])
{
int num_of_elements=sizeof(numA)/sizeof(int);
return num_of_elements;
}