#include <iostream.h>
float Total(float a[],int num);
const int SIZE = 10;
main()
{
float * f = new float [SIZE];
for (int i=0;i<SIZE;i++)
f[i]=i+i; //*(f+i)
cout <<"Sum = " << Total( f ,SIZE) <<endl;
cout << "Average = " << Total(f,SIZE)/SIZE;
delete []f;
return 0 ;
}
float Total(float a[],int num)
{
int i;
float sum = 0;
for (i=0; i<num ; i++)
sum += a[i];
return sum;
}
|