Integer8. A two-digit number is given. Output the number obtained by swapping the digits of the original number.

Solution in Python 3:

import random

N = random.randrange(10,100)
print("Number: ", N)
d1 = int(N/10)
d0 = N%10
N_new = d0*10 + d1
print("Tens: ", d1)
print("Units: ", d0)
print("New number: ", N_new)

Solution C++:

#include<iostream>
using namespace std;
int main(){
int n, f, s, n_new;
cout << "Enter the number N: ";
cin >> n;
f = int(n/10);
s = n%10;
n_new = s*10+f;
cout << "Number obtained by swapping the digits: " << n_new;
return 0;
}