what is the logic to print reverse of a number code example
Example 1: reverse intergers in python
# Get the number from user manually
num = int(input("Enter your favourite number: "))
# Initiate value to null
test_num = 0
# Check using while loop
while(num>0):
#Logic
remainder = num % 10
test_num = (test_num * 10) + remainder
num = num
# Display the result
print("The reverse number is : {}".format(test_num))
Example 2: print reverse number
void printReverse(int n) {
if (n < 1) return;
cout << n << endl;
printReverse(n - 1);
}
printReverse(10);