Programming Logic:
To convert or change the octal number to binary number replace the each octal digits by a binary number using octal to binary chart.
For example take 25: Binary of 2 is 010 and Binary of 5 is 101.
Therefore binary of octal 25 is: 010101
Program to convert Octal to Binary C++:
#include<iostream>
using namespace std;
#define MAX 1000
int main()
{
char octalNumber[MAX];
long int i=0;
cout<<"Enter any octal number: ";
cin>>octalNumber;
cout<<"Equivalent binary value: ";
while(octalNumber[i])
{
switch(octalNumber[i])
{
case '0': cout<<"000";
break;
case '1': cout<<"001";
break;
case '2': cout<<"010";
break;
case '3': cout<<"011";
break;
case '4': cout<<"100";
break;
case '5': cout<<"101";
break;
case '6': cout<<"110";
break;
case '7': cout<<"111";
break;
default: cout<<"nInvalid octal digit "<<octalNumber[i];
return 0;
}
i++;
}
return 0;
}