Java program to reverse number
Java programming source code
- class ReverseNumber
- {
- public static void main(String args[])
- {
- System.out.println("Enter the number to reverse");
- int n=54321,
- int reverse = 0;
- while( n != 0 )
- {
- reverse = reverse * 10;
- reverse = reverse + n%10;
- n = n/10;
- }
- System.out.println("Reverse number is "+reverse);
- }
- }
Output of program:
Reverse number is 12345
Comments
Post a Comment