Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class ForLoopReverseDemo
- {
- public static void main(String args[])
- {
- int num=0;
- int reversenum =0;
- System.out.println("Input your number and press enter: ");
- Scanner in = new Scanner(System.in);
- num = in.nextInt();
- for( ;num != 0; )
- {
- reversenum = reversenum * 10;
- reversenum = reversenum + num%10;
- num = num/10;
- }
- System.out.println("Reverse of specified number is: "+reversenum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement