question about array

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2004
Posts: 2
Reputation: sweetbaby is an unknown quantity at this point 
Solved Threads: 0
sweetbaby sweetbaby is offline Offline
Newbie Poster

question about array

 
-1
  #1
Nov 11th, 2004
hi, all.
i have some problems to do array.
i am supposed to get the average and sum in given number of array.
but, i only got 1 in my all answers.
please, tell me what was wrong in my program.
thank you.

//hw for array



#include <iostream>

#include <iomanip>

#include <cmath>


using namespace std;



float ave(float x[],int n);

float sum(float x[],int n );

float diff(float x,float y);

float large(float x[],int n );

float small(float x[],int n);



const float size=10;


int main()

{


float array[10]={24.9,18.5,7.9,14.3,56.1,37.8,41.5,28.3,32.7,19.4};


cout<< "\na) \n\n";

cout<<"\naverage of these numbers: "<<ave<<endl;



return 0;

}



float ave(float x[],int n)

{
int i;
float sum=0;

for (i=0;i<n;i++)

sum +=x[i];

return (sum/n);

}
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 56
Reputation: jasweb2002 is an unknown quantity at this point 
Solved Threads: 2
jasweb2002 jasweb2002 is offline Offline
Junior Poster in Training

Re: question about array

 
0
  #2
Nov 11th, 2004
cout<<"\naverage of these numbers: "<<ave<<endl;

You are not passing any of you parameters in ave. I am surpised it is compiling at all. Should look like ave(array, 10).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC