# Passing Arrays in Functions

#include<iostream.h>
void get_data(float num[],unsigned int *j);
void demo(float num[], unsigned int c, float *ave);
void output(float num[], unsigned int c, float ave);
float demopro(float k);
main()
{
unsigned int c = 0;
float num[20];
float average;

get_data(num,&c);
cout << c << '\n';
cout << num[0] << "*" << num[1]<< "*" << num[2] << "*" << num[3] << "\n";

demo(num, 4, &average);
output(num, 4, average);

return 0;
}
//============== FUNCTION g e t _ d a t a ====================
void get_data(float num[10], unsigned int *j)
{

for( unsigned int i = 0; i < 4; i++)
{
num[i] = i * 2 +3;
*j += i;
}

}
//============= FUNCTION f i n d _ a v e r a g e ====================
void demo(float num[10], unsigned int c, float *ave)
{
float sum = 0.0;
for (unsigned int i = 0; i < c ; i++)
sum += num[i];
*ave = demopro( sum);

}
//============== FUNCTION o u t p u t ====================
void output(float num[10], unsigned int c, float ave)
{
for (unsigned int k = 0; k < c - 1 ; k++)
cout << num[k] << " + ";
cout << '\n' << num[c - 1] << "*" << ave;
}
//====== F U N C T I O N d e m o p r o ==============
float demopro(float k)
{
float rh;
rh = float (k) + 3.0;
return rh;
}
/*
6
3*5*7*9
3 + 5 + 7 +
9*27
*/