Need Help on functions and Arrays

Write a program which will do the following. Make sure you use functions in your program. Do not use any global variables.
1.Read numbers from the keyboard into an array. Make your array large enough to allow the user to enter 30 numbers. (call this function Fill)
2.Compute the average of the numbers entered. (call this function Average)
3.Print out those numbers in the array which are greater than the average. (call this function AboveAvg)
4.Write a function which will print out the numbers in the array. The function should have a parameter which indicates the order in which to print the values. If this parameter contains the value 1, print the array from beginning to end. If this parameter contains the value -1, print the array from end to beginning. The function should print one number on each line. Use this function to print the array forwards and backwards. Print a message before calling the function to describe what is being printed. (call this function PrintwOrder)
5.Write a function which will return the number of entries in the array which contain zero. Use this function to print the number of zeros in the array. (call this function ZeroCount)
6.Write a function which will return true if all the numbers in the array are positive (greater than zero) and will return false if any number in the array is not positive (less than or equal to zero). Use the function to print a message indicating whether all the values in the array are positive. (call this function Parity)

This what I have so far:
using namespace std;
void Fill(int num[]);
void Average();
void AboveAvg();
void PrintwOrder();
void ZeroCount();
void Parity();
int main()


int num[30];
int temp;
return 0;


void Fill(int num[])


for(int i=0; i<30; i++)


cout<<"Enter value number "<<i+1<<endl;


Well, that's a start. Now you really need to be more specific what exactly you need help with. You also need to have tried to do it yourself already as well. I am quite sure there is no one here coming and writing this whole thing for you just like that.
snowright is write. Try it out then if it does not work then post your code with what you have tried.
But here is something. Have to Average() return the average so you can use it in the AboveAvg().
Last edited on
Topic archived. No new replies allowed.