C++ Programming Code Examples C++ > Conversions Code Examples Convert Octal number to Binary number Convert Octal number to Binary number To convert octal number to binary number in C++ programming, you have to ask to the user to enter the octal number to convert it into binary number to display the equivalent value in binary format as shown here in the following program. Following C++ program ask to the user to enter any number in octal to convert it into binary, then display the result on the screen: #include<iostream.h> #include<conio.h> void main() { clrscr(); long int i=0; char octnum[1000]; cout<<"Enter any Octal Number : "; cin>>octnum; cout<<"Equivalent Binary Value = "; while(octnum[i]) { switch(octnum[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 "<<octnum[i]; break; } i++; } getch(); }