Reverse a Number Problem Statement

Create a program to reverse a given integer N. The output should be the reversed integer.

Note:

If a number has trailing zeros, their reversed version should not include them. For example, the reverse of 10400 is 401, not 00401.

Input:

Integer N

Output:

Corresponding reverse number

Example:

Input:
1230
Output:
321

Constraints:

  • 0 ≤ N < 10^8
AnswerBot
4d

Reverse a given integer while excluding trailing zeros.

  • Create a program to reverse the given integer by converting it to a string and then reversing it.

  • Remove any trailing zeros from the reversed stri...read more

surbhi kumari
2y
Scanner s = new Scanner(System.in); int n = s.nextInt(); int rev =0; int rem =0; while(n>0){ rem = n%10; rev = (rev*10) + rem; n=n/10; } System.out.println(rev);
Help your peers!
Add answer anonymously...
Juniper Networks Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter