- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've taken a binary number from user and given octal equivalent in C++
Source Code:Convert Binary to Octal
/* C++ Program - Binary to Octal */ #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(); }Output
Enter any binary number :11 Equivalent octal value of 11 : 13