#include<iostream>
using namespace std;
int number(int (&a)[10])
{
int n= sizeof(a)/sizeof(a[0]);
return n;
}
int main()
{
int n;
cout << " Enter the number of elements ";
cin >> n;
int a[10];
cout << "Enter array elements : ";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<" The number of elements according to main is "<< sizeof(a)/sizeof(a[0])<<endl;
cout<<" The number of elements in the function number is " << number(a);
}
In the above code in the main function "number(a)" Here what exactly are we passing and what is taken by the method. and how does the code work in the function.and what is happening if we are not using "&" symbol in the number function.
My understanding is we are passing a pointer to the first element into the function but I dont know properly.