In this program, we are going to share a C++ program to convert binary to octal number. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a program for C++ program to convert binary to octal number.
To increase your C++ knowledge, practice all C++ programs:
Copy the below C++ program and execute it with the help of C++ compiler. At the end of this program, We have shared the output of this program.
Also read: C++ program to convert octal to the binary number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<iostream.h> #include<conio.h> void main() { clrscr(); long int binnum, rem, quot; int octnum[100], i=1, j; cout<<"Enter any binary number : "; cin>>binnum; quot=binnum; while(quot!=0) { octnum[i++]=quot%8; quot=quot/8; } cout<<"Equivalent octal value of "<<binnum<<" :\n"; for(j=i-1; j>0; j--) { cout<<octnum[j]; } getch(); } |
Enter any binary number : 11
Equivalent octal value of 11 = 13
Liked this program? Do Like & share with your friends.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.