Convert Decimal to Binary in C++

Here you will get program to convert a number from decimal to binary in C++.

 

How to convert decimal number to binary?
  • Divide the number by 2 and save the remainder somewhere.
  • Divide the quotient with 2 again and save the remainder somewhere.
  • Repeat the process until 1 is left as quotient.
  • Now write the remainders in reverse order.
This program can only convert non decimal numbers.

 

Program for Decimal to Binary in C++

 

Output
Enter a number:5
The binary conversion of 5 is 101

Leave a Reply

Your email address will not be published. Required fields are marked *