Reverse Digits

Practice this coding question on Coding Gurukul.

Problem statement

A maintenance display reads an equipment number from its last decimal digit back to its first. Convert that reversed digit sequence into an ordinary integer. Your task Reverse the decimal digits of the nonnegative integer n and print the resulting integer. Important details Any zeros that become leading zeros are discarded in the numeric result. Zeros inside the reversed number remain in place. The number zero reverses to zero. Inputs use ordinary decimal notation without redundant leading zeros. You may repeatedly extract the last digit with remainder and integer division; make sure the accumulator can hold the reversed value. This is digit reversal, not reversing the bits of the number. Worked example For n = 12040, the reversed digits are 04021. As an integer this is 4021, so the output has no leading zero.

Input format

One integer n.

Output format

Print the integer formed by reversing its digits.

Constraints

0 <= n <= 1000000000.

Sample input

12040

Sample output

4021

Sign in to run or submit a solution in C++, Java or Python.