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
4mo

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!
Select
Add answer anonymously...

Top Software Engineer Interview Questions Asked at Juniper Networks

Q. Implement your own hashmap.
Q. Write a program to reverse an integer.
Q. What is the difference between declaring an array int arr[5] and allocating memo...read more
Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits