Jon Jon - 1 year ago 80
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: ";
cout<<"second number: ";
//now the variable both should store the number 12
int both = ?????????;

Answer Source
int result = num1 * 10 + num2;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download