Void function

HEy everyone thanks for your time. the code i have here is used to find the sum,average and product , i got them to work in a normal function which returns a value but now i want to try it in a void function. i have the other parts of the program except for the average part disabled when i call the function in int maini always end up with 1. The numbers from the user are being stored in a array.

//this is where i want the program to display the average
cout<<"The average of the five numbers is:"<<averageCal<<endl;

First averageCal is a function, you need the (). Second since averageCal doesn't return a value you can't try to print this non-value. Since your function is printing to the screen just call the function.

But I really recommend you return the average from the function instead of the void function, and don't do the printout in the function. Try to have your functions do as few things as possible. In this case just preform the calculation.

I also suggest you add another parameter to your call, the size of the array. And then use the parameter in your loop to replace the "magic number" 5. This way you can use this function with any size array, not just an array with 5 elements.

Thanks for your reply and yes i did the entire program and used the return but i wanted to see how can i make it work with with void, how do i call it in my int main cause every time i try to call it is displays a 1 instead of the right answer.

This will work the same for static arrays, but will produce a compiler error if you use it incorrectly (such as with a dynamic array, or a pointer) rather than compiling okay and screwing up at runtime.