Jul 25, 2011 at 7:56pm UTC
#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
Jul 25, 2011 at 8:23pm UTC
You spelled the function wrong in its definition.
1 2
double computeaverage (int [],int );
double computer average(int a[],int n) { }
Last edited on Jul 25, 2011 at 8:24pm UTC
Jul 25, 2011 at 8:36pm UTC
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)â
"
Jul 25, 2011 at 9:05pm UTC
cout<<"average" <<computeaverage(a,n)<<endl;
This line.
Where did 'a' come from? Your pointer is named 'p'.