C++ Programming Code Examples C++ > Conversions Code Examples Convert Decimal to Octal Convert Decimal to Octal To convert decimal number to octal number in C++ programming, you have to ask to the user to enter the decimal number to convert it into octal number to display the equivalent value in octal format as shown here in the following program. Following C++ program ask to the user to enter any number in decimal to convert it into octal, then display the result on the screen : #include<iostream.h> #include<conio.h> void main() { clrscr(); long int decnum, rem, quot; int i=1, j, octnum[100]; cout<<"Enter any decimal number : "; cin>>decnum; quot=decnum; while(quot!=0) { octnum[i++]=quot%8; quot=quot/8; } cout<<"Equivalent octal value of "<<decnum<<" is : \n"; for(j=i-1; j>0; j--) { cout<<octnum[j]; } getch(); }