How to find the number of elements in an array and pass it to a function in this code?
#include <iostream> using namespace std; int aver(int data[]) { float add=0; int n; for(int i = 0; i <=my_num-2; ++i) //I need to pass the number of elements on the array in the main function// { cout<<"value of i "<<i<<" "; cout<<num<<" "; cout<< data[i] << ' '<<"Array No. "<<i+1<<endl; int x=sizeof(data); add=add+data[i]; cout<<endl; n=i+1; } cout<<"The addition is = "<<add<<endl; float ave=add/n; cout<<"The Average of the six numbers is = "<<ave<<endl; } int main() { int num=0; cout<<"This Program Adds the elements of an Array"<<endl; cout<<" And calculates their Average"<<endl<<endl; cout<<"how many elements do you want in the Array? "; cin>>num; int data[num]; for(int j=0;j<=(num-1); ++j){ data[num]; cout<<"enter "<<j<<" Element "; cin>>data[j]; } int my_num=num aver(data); }