Description
Write a java program to reverse a given number by using only numeric operators.Suppose, if you are given an input of 4567 then the output should be 7654.In the program below, we have only used the modulus or remainder and / operator.Following is the complete program.
ReverseNumber.javapackage com.devglan; public class ReverseNumber { public int reverseNumber(int number){ int reverse = 0; while(number != 0){ reverse = (reverse*10)+(number%10); number = number/10; } return reverse; } public static void main(String a[]){ ReverseNumber reverseNumber = new ReverseNumber(); System.out.println("Reversed Number: " + reverseNumber.reverseNumber(3579)); } }