I have to write five function which i do not have to put in "main" but have to call inside main. i hade come up with a code which did not work and was incomplete but i was futher told i have to use global variables and not local variable like i had. Bythe way i am a nowbie so please try to make clear comments so i can see what is been done.
I have to (1) make a function to input an array of numbers(the number of elements not specified) with the length and elements as variables.
(2) function to add all the elements
(3) function to display original array and sum
(4) function to find average and display
(5) functon to find square of individual elements and sum of array
my code was as follows:
#include<iostream>
using namespace std;
int length; // length of array
int elements; //elements of the array
int t; // counter
int y[]; // array
int sum=0;
void input(length,elements)
{
cout <<" How many alements is the array to have\n";
cin>>length;
for(t=o;t<length;t++)
{
cout<<"Enter elements\n";
cin>>elements;
return;
}
void sum(length,y[],t,sum)
{
sum = 0;
for(t=0,t<length,t++)
{
sum += y[t]
}
cout<< sum;
return;
}
void display(t,y[],length);
{
for(t=0,t<length,t++)
{
cout<< y[t]\n
return;
}
}
i hope you will make the solution easy enough for me to understand