I would like to be able to have a function that simply gets two input values from the user and returns those values for the main function to work with.
I would like the values a and b to be reside just in the getvals function and be passed into the main function as x and y.
I think I may be going about things the wrong way here as I have searched a lot and can't find any similar ways to do this but any help would be appreciated.
#include <iostream>
using namespace std;
int x = 100;
int y = 42;
int result1;
int result2;
int a;
int b;
int getvals(int,int)
{
cout << "input value a ";
cin >> a;
cout << "input value b ";
cin >> b;
return a,b;
}
int main()
{
getvals(x,y);
result1 = x + y;
cout << "\n\n";
cout << " x + y = " << result1;
return 0;
}