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
Post A Comment:
0 comments: