Friday, June 29, 2018

Reverse the number !!

public class MathsSol {
    public static void main(String args[]) {
        int a = 4958;
        reverseNumber(a);
    }
    public static void reverseNumber(int num) {
        int remainder = 0;
        while (num != 0) {
            remainder = remainder * 10 + num % 10;
            num = num / 10;
        }
        System.out.println(remainder);
    }
}

Output:
8594

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...