Reversing a decimal number

Reversing a decimal number is a favourite programming problem in the technical interviews. Below is the problem statement and the solution implemented in Java.

Problem statement

Write an optimal program to reverse the digits in a decimal number without converting it to a string. Example: 123.45 -> 54.321

Solution

 

Sample run

 

Leave a Reply

avatar
300
  Subscribe  
Notify of