C++ Programming Code Examples C++ > Conversions Code Examples Convert Decimal to Binary Convert Decimal to Binary To convert decimal number to binary number in C++ programming, you have to ask to the user to enter the decimal 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 decimal format to convert it into binary, then display the result on the screen : #include<iostream.h> #include<conio.h> void main() { clrscr(); long int decnum, rem, quot; int binnum[100], i=1, j; cout<<"Enter any decimal number : "; cin>>decnum; quot=decnum; while(quot!=0) { binnum[i++]=quot%2; quot=quot/2; } cout<<"Equivalent binary value of "<<decnum<<" :\n"; for(j=i-1; j>0; j--) { cout<<binnum[j]; } getch(); }