## Octal to Binary in C Programming Language

Let’s understand how to Convert Octal Number to Binary in C Programming Language.  In this C program, in order to convert octal to binary, we have created a function named “octToBinaryConversion” and called the same in the main program.

## C Program to Convert Octal to Binary

```#include <stdio.h>

/*Learn C Programming at CodeAtGlance.com*/

#include <math.h>

long octToBinaryConversion(int octalnum)

{

int dec_number = 0, i = 0;

long binarynum = 0;

while(octalnum != 0)

{

dec_number = dec_number + (octalnum%10) * pow(8,i);

i++;

octalnum = octalnum / 10;

}
i = 1;
while (dec_number != 0)

{
binarynum = binarynum + (dec_number % 2) * i;

dec_number = dec_number / 2;

i = i * 10;

}
}

int main()
{
int octalnum;

printf("Enter an octal number: ");

scanf("%d", &octalnum);

printf("Equivalent binary number is: %ld", octToBinaryConversion(octalnum));

return 0;
}```

Now let’s have a look at the output of the above example code:

Output:

Enter an octal number: 67
Equivalent binary number is: 110111