• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
June 08, 2022 |2.6K Views

Octal to Decimal Conversion

  Share   Like
Description
Discussion

Given an octal number as input, we need to write a program to convert the given octal number into equivalent decimal number.

Examples:

Input : 67
Output: 55

Input : 512
Output: 330

Input : 123
Output: 83
The idea is to extract the digits of a given octal number starting from the rightmost digit and keep a variable dec_value. At the time of extracting digits from the octal number, multiply the digit with the proper base (Power of 8) and add it to the variable dec_value. In the end, the variable dec_value will store the required decimal number.

Octal to Decimal Conversion: https://www.geeksforgeeks.org/program-octal-decimal-conversion/