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

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Previous article

Cut the Sticks