public class ReverseNumber {
public static void main(String[] args) {
int number = 6789;
int reversedNumber = 0;
int temp = 0;
while(number > 0){
temp = number%10;
reversedNumber = reversedNumber * 10 + temp;
number = number/10;
}
System.out.println("Reversed Number is: " + reversedNumber);
}
}
/*
Output of this Number Reverse program would be
Reversed Number is: 9876
*/
No comments:
Post a Comment