Hello folks I have a question to ask in regard to functions and passing information between them. I'm taking an problem solving class and well the instructor went from simple cout and cin to functions and has been really vague since the class is mostly on problem solving and not supposed to focus on C++. Yeah.
Anyway my problem is just passing the values from one function to another. I'm trying to have the user input two numbers in one function (requirement of the assignment) and then calculate the sum of the numbers and print them in the second function. Sounds simple but for the life of me I can't get the functions to pass data and I don't really understand how the feature works anyway. I would appreciate it if someone could offer a better explaination of how this works and an idea on how I could get my solution. The code is below along with the current error.
error C2660: 'calcPrint' : function does not take 0 arguments
#include <iostream>
using namespace std;
int inputNumbers ()
{
int num1, num2;
cout << "Please enter the first number: "; //Output to user for num1
cin >> num1; //Input from user to num1
cout << "And now enter the second number: "; //Output to user for num2
cin >> num2; //Input from user to num2
return 0;
}
int calcPrint (int num1, int num2)
{
int sum;
sum = num1 + num2;
cout << "You entered " << num1 << "and " << num2 << endl;
cout << "The sum is " << sum << endl;
return num1, num2;
}
int main ()
{
inputNumbers (); //Calls up inputNumbers function
calcPrint (); //Calls up CalcPrint function
return 0;
}