package com.tutorial4u;
import java.util.Scanner;
public class ReverseInteger {
public static void main(String[] args) {
int num,reverse=0;
System.out.print("Enter any number to reverse : ");
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
while(num!=0){
reverse = reverse*10;
reverse=reverse+num%10;
num= num/10;
}
System.out.println("Reverse number is : "+reverse);
}
}
Output:
Enter
any number to reverse : 2356
Reverse
number is : 6532
No comments:
Post a Comment