Sunday, May 12, 2019

how will you reverse the number?

Problem statement:
how do you reverse the given number?
  1. class A {
  2.     public static void main(String args[]) {
  3.         int n = 243589;
  4.         int r = 0;
  5.         while (n != 0) {
  6.             r = r * 10 + n % 10;
  7.             n = n / 10;
  8.         }
  9.         System.out.println(r);
  10.     }
  11. }
Output:
985342
Asked in - Synechron technologies

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...