Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javalab;
- import java.util.Scanner;
- class Javalab
- {
- public static void main(String args[])
- {
- int n, reverse = 0;
- System.out.println("Enter a number to reverse");
- Scanner in = new Scanner(System.in);
- n = in.nextInt();
- while(n != 0)
- {
- reverse = reverse * 10;
- reverse = reverse + n%10;
- n = n/10;
- }
- System.out.println("Reverse of the number is " + reverse);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement