It is simple c or c++ program that convert octal base number into equivalent binary numbers.

In this resource I will explain the procedure to convert octal number to binary number with the help of screen shoots.

At first know about the what is the octal number and binary number.

In octal number each digits does not exceed the value of 8.

That is the valid digits in octal number system is

1, 2, 3, 4, 5, 6, 7. If we want to write number 9 then in octal it is 11.

Just like 55

In binary number system only two digits is valid, which is 0, 1.

binary number is 1001

If we talk about the simple conversion of octal to binary then replace each octal digits to equivalent binary digit. means that the if we want to convert octal number 55

5

i.e. 55

In this resource I will explain the procedure to convert octal number to binary number with the help of screen shoots.

At first know about the what is the octal number and binary number.

**Octal number**is the number which represented in 8 base. Means that the number represented in 8 base is called octal number.In octal number each digits does not exceed the value of 8.

That is the valid digits in octal number system is

1, 2, 3, 4, 5, 6, 7. If we want to write number 9 then in octal it is 11.

Just like 55

_{8}is octal number.**Binary number**is the number which is represented in base 2.In binary number system only two digits is valid, which is 0, 1.

binary number is 1001

_{2}If we talk about the simple conversion of octal to binary then replace each octal digits to equivalent binary digit. means that the if we want to convert octal number 55

_{8}to binary then5

_{8}=101_{2}i.e. 55

_{8}=101101_{2}If we talk about the programming aspect to convert octal to binary number then we need to follow specific procedure.**Octal number first convert into decimal number after that convert decimal number to binary number.**Lets see the code in c or c++ programming language./*By bharat kumar dhakerwww.computersciencearticle.in*/ #include <stdio.h> #include <conio.h> #include <stdlib.h> int power_Calulate(int,int); int Octal_to_DecimalConvert(int); void main() { int number;printf("enter number in 8 basen"); scanf("%d",&number); int decimal=Octal_to_DecimalConvert(number); char binary[7];int i; for( i = 6; i >= 0; i--) { if( (1 << i) & decimal) binary[6 - i] = '1'; else binary[6 - i] = '0'; } binary[7] = 0; printf("After convert binary value isn %s",binary); getch(); } int Octal_to_DecimalConvert(int number) { int resultDec = 0; int n = 0; int numberTemp = 0; if (number < 10) return number; else { while (number / 10) { numberTemp = number % 10; resultDec = (numberTemp * power_Calulate(8,n)); n++; number /= 10; } resultDec = (number *power_Calulate(8,n)); return resultDec; } } int power_Calulate(int base, int power) { int i,temp =1; if(power==0) return(1); if(power==1) return(base); else { for(i=1;i<=power;i++) temp = temp*base; return(temp); } }

**Source Code: Octal To Binary **

**Output:**

Lets take example to convert.

We want to convert 11_{8} into binary.

Then output is as shown in figure.

One Response

Hello, I am ida, please help me to built one program using C++, the program is to enable process of converting number to binary or octal number format.Program will start by requesting user to key-in any number.Then, the user can choose whether want to convert the number to binary number format or octal number format.This program is should generate the code based on the selection user.The output will be display to user based on the selection before.All the process in converting number to binary or octal format number will be implement using stack with linked list.