# C++ program to convert Octal to Decimal

In this article, we are going to learn how to convert an Octal number to an equivalent Decimal number.
Here we are going to learn about two number systems one is binary and another is Decimal. Octal numbers are based on 8 numbers. Decimal numbers are base 10 numbers and are represented in numbers from 0 to 9.

### C++ program to convert Octal number to Decimal number

```#include<iostream>
#include <math.h>
using namespace std;

int main()
{
int octNum;
int tmpOctNo;
int decNum;
int rem, place;

cout <<"Please enter an octal number: ";
cin >> octNum;

tmpOctNo = octNum;

decNum = 0;
place = 0;

while(tmpOctNo > 0)
{

rem = tmpOctNo % 10;

decNum += pow(8, place) * rem;

tmpOctNo =tmpOctNo/10;

place++;
}

cout<< "\nDecimal Equivalent to Octal number = " << octNum << " is "<< decNum;

return 0;
}
```

Output

```Please enter an octal number: 4

Decimal Equivalent to Octal number = 4 is 4

Please enter an octal number: 10

Decimal Equivalent to Octal number = 10 is 8
```