Getting the two digits from a double digit

int double_digit, first_digit, second_digit. I ask the user to enter a value for "double_digit." User enters 24, how can I separate the 2 and 4 and place the 2 as the value for "first_digit" and 4 as the "second_digit"?

I know this will involve / and % to get the answer but cant figure out the calculations.

Thanks
1
2
3
cin >> double_digit;
first_digit = double_digit / 10;
second_digit = double_digit % 10;


That is assuming the user enters a single/double digit number.
Last edited on
Thanks chew, it works...
Topic archived. No new replies allowed.