How so I implement the mean1d function in order to find the mean?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
using namespace std;
int main()
{
//I'll be making a 1 dimensional array
int array1d[25];
array1d[0] = 9;
array1d[1] = 8;
array1d[2] = 7;
array1d[3] = 5;
array1d[4] = 3;
array1d[5] = 7;
array1d[6] = 4;
array1d[7] = 7;
int array1d_size = 8;
cout << "The original array is: { ";
for (int i=0; i<array1d_size; i++)
cout << array1d[i] << " ";
cout << "} " << endl;
double the_mean = mean1d(array1d, array1d_size);
cout << "\n=====> The mean is: " << the_mean;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
using namespace std;
const int SIZE = 25;
double the_mean(int[], int);//Function Prototype
int main()
{
double mean;
int array1d[SIZE] = { 9, 8, 7, 5, 3, 7, 4, 7 };
cout << "The original array is: { ";
for (int i = 0; i<SIZE; i++)
cout << array1d[i] << " ";
cout << "} " << endl;
mean = the_mean(array1d, SIZE);//Call to function
cout << "\n=====> The mean is: " << mean;
}
double the_mean(int array1d[], int SIZE){//Function
//Code Here
}
|
http://www.cplusplus.com/doc/tutorial/functions/
Last edited on
Topic archived. No new replies allowed.