How could I use cin
to insert values for the function?
cin >> addNumber();
cout << addNumber() << endl;
I am not sure if I used these lines above properly.
What command/word or whatever it is called should I use to be able to do so? I'm trying to add a value for the variables x
and y
to add those two numbers and print the sum.
#include <iostream>
using namespace std;
int addNumber(int x, int y)
{
int answer = x + y;
return answer;
}
int main()
{
cin >> addNumber();
cout << addNumber() << endl;
return 0;
}