daily pastebin goal
1%
SHARE
TWEET

Reverse Number

a guest Feb 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. auto reverseNumber(int num) -> int
  5. {
  6.     /*! Find total digits in num */
  7.     int digit = static_cast<int>(log10(num));
  8.  
  9.     /*! Basic Condition */
  10.     if(num == 0)
  11.         return 0;
  12.    
  13.     return ((num % 10 * pow(10, digit)) + reverseNumber(num / 10));
  14. }
  15.  
  16. int main()
  17. {
  18.    std::cout << reverseNumber(123);
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top