Explore
ProGrad Programs
About Us

Edit
Reply




Edit

Convert Octal to Decimal number in C, C++, Java and python | FACE Prep

Published on 10 Mar 2020

Program to convert a number from octal to decimal is discussed here. Given an octal number, convert the given octal number into its equivalent decimal number.


For example, octal number 1907 has to be converted to decimal.

7 * 8^0 = 7
0 * 8^1 = 0
9 * 8^2 = 576
1 * 8^3 = 512

512 + 576 + 0 + 7 = 1095

The decimal equivalent of octal number 1907 is 1095.

octal to decimal

Algorithm to convert a number from octal to decimal


  • Input the octal number.
  • Find the number of digits in the number.
  • Let it have n digits.
  • Multiply each digit in the number with 8n-1, when the digit is in the nth position.
  • Add all digits after multiplication.


Program to convert a number from octal to decimal


C
C++
Java
Python 3

Output
Input- Enter an octal number: 350 Output- Decimal Equivalent :232


Time complexity:O(n)


Recommended Programs






If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in