Reverse Number -Java Program

package javaPrograms;
import java.util.Scanner;

public class ReverseNumber
{

public static void main(String a[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter no. to generate Reverse Number:\n");

   int n=sc.nextInt();

   int originalNumber=n;
   int reverseNumber = 0;
 
   while(n>0)
   {
    int r=n%10;
    n=n/10;
    reverseNumber=reverseNumber*10+r;
     
   }

   System.out.println("Reverse Number of "+originalNumber+" is : "+reverseNumber);
 

}
}


Output
------------------------------------------------------------------------------------------------------------------------
Enter no. to generate Reverse Number:

344
Reverse Number of 344 is : 443

Post a Comment

0 Comments