Octal to Decimal

    0

    1

    Giovanny Gongora

    Codiga's C++ Recipes

    Convert octal number to decimal

    #include <iostream>
    #include <cmath>
    
    using namespace std;
    int octalToDecimal(int octalNumber);
    // Function to convert octal number to decimal
    int octalToDecimal(int octalNumber)
    {
      int decimalNumber = 0, i = 0, rem;
      while (octalNumber != 0)
      {
        rem = octalNumber % 10;
        octalNumber /= 10;
        decimalNumber += rem * pow(8, i);
        ++i;
      }
      return decimalNumber;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.