Jon Jon - 1 month ago 8
C++ Question

How to store separately inputted numbers in same variable C++?

How can I store two separately inputted numbers into one variable that stores the first number in the tens place, and then the second number in the ones place? For example...

int num1 = 0;
int num2 = 0;
cout<<"first number: ";
cin>>num1;
cout<<"second number: ";
cin>>num2;
//now the variable both should store the number 12
int both = ?????????;

Answer
int result = num1 * 10 + num2;