Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.
Reversing a number involves swapping the digit at the first position with the last digit and the second digit with the second last digit, and so on until the middle digit.
Here are the steps to reverse the number.
Now let’s look at the below Java program that prints the number in reverse order.
import java.util.Scanner;
public class Reverse
{
public static void main(String args[])
{
int x, y, k = 0;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number you want to reverse:");
x = s.nextInt();
while(x > 0)
{
n = x % 10;
k = k * 10 + y;
x = x / 10;
}
System.out.println("Reverse number is "+k);
}
}
Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.
Start Free TestingEarn resume-worthy Selenium certifications that help you land a top job.
Learn MoreTest orchestration and execution cloud of 3000+ browsers and OS
24/7 support
Enterprise grade security
Fastest test execution cloud