this is driving me nuts.....the object is to generate the sum of numbers 1-10. that number, which is 55, is generated with the function COMPUTE_SUM.

The data does not display correctly as SUM keeps coming back with 0.

The catch is....the SUM has to be displayed within MAIN and I cannot use global variables.

I had placed the cout statement outside the loop and it will generate the proper sum but I'm guessing that is not within MAIN.

Here's the given code. All help is appreciated.

Code:#include<iostream> using namespace std; void compute_sum(int); void main() { int sum = 0; int n = 10; compute_sum(n); cout << "The sum is " << sum << endl; } void compute_sum(int x) { int sum = 0; int num = 1; while (num <= x) { sum += num; num++; } }