I have to ge t the result using call by reference. I'm receiving 4 errors???
from my understanding, I have 'declared' total before main. Quite frankly, I'm not getting why not declared it on display_output nonetheless??
and why total is still not being recognized??
Thanks in advance for the help!
eddy
____________________________________
//This program allows the user to enter 3 integers
//then computes their sum and outputs the result.
#include <iostream>
using namespace std;
void get_input (int& num1, int& num2, int& num3);
int find_sum (int& num1, int& num2, int& num3);
void display_output(int& num1, int& num2, int& num3, int& total);
int main()
{
int num1, num2, num3, sum, total;
char answer;
// get input from user
do
{
get_input (num1, num2, num3);
sum= find_sum(num1, num2, num3);
display_output(num1, num2, num3, total);
cout << "Do you want to continue? (Enter Yes or No)"<<endl;
cin >> answer;
}
while (answer != 'n' && answer !='N');
return 0;
}
void get_input(int a, int b, int c)
{
cout << "Enter the first number" <<endl;
cin >> a;
cout << "Enter the second number" <<endl;
cin >> b;
cout << "Enter the third number" <<endl;
cin >> c;
}
int find_sum (int a, int b, int c)
{
return a+b+c;
}
void display_output(int a, int b, int c, int total)
{
cout << "The sum of" << a << b << c << " is "
<< total << endl;
}