Reverse a number

    0

    0

    Giovanny Gongora

    Codiga's C++ Recipes

    Reverse a number from input

    using namespace std;
    int reverseNumber() {
      int number, reverse = 0;
      cout << "Enter a Number to Reverse and press Enter: ";
      cin >> number;
      for(; number != 0 ;){
        reverse = reverse * 10;
        reverse = reverse + number%10;
        number = number/10;
      }
      cout << "Reversed Number is:  " << reverse;
      return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.