Write a java program to display the reverse of a given number.

Program Code:
import java.io.*;
class Reverse
{
public static void main(String args[])
{
int n=579;
int rev=0,digit;
while(n>0)
{
digit=n%10;
rev=(rev*10)+digit;
n=n/10;
System.out.println("the reverse of number is" +rev);
}
}
}

Output:
The reverse of number is 9
The reverse of number is 97
The reverse of number is 975

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: