pointers

#include <iostream>

using namespace std;
double computeaverage (int [],int );
int main()
{
int *p;
int n;

cout<<"Enter number of data ";
cin>>n;
p= new int[n];
for (int i=0;i<n;i++)

cin>>p[i];
cout<<"average"<<computeaverage(a,n)<<endl;


return 0;
}
double computeraverage(int a[],int n)
{
double total=0.0;
for (int i=0;i<n; i++)

total=total+a[i];

return (total/n);
}

im i declaring the fuction wrong
You spelled the function wrong in its definition.

1
2
double computeaverage (int [],int );
double computeraverage(int a[],int n) { }
Last edited on
yes i fix that but still not working im new to this
this is what is says
"
average.cpp:18: error: invalid conversion from âintâ to âint*â
average.cpp:18: error: initializing argument 1 of âdouble computeaverage(int*, int)â
"
cout<<"average"<<computeaverage(a,n)<<endl;

This line.

Where did 'a' come from? Your pointer is named 'p'.
Topic archived. No new replies allowed.