Program to Convert Decimal to Binary in C++ (vice versa)
1. Program to convert Decimal to Binary in C++
In this program, we will ask the user to enter the number which user wants to convert into binary.
Decimal to Binary Conversion Algorithm:
1 Step: At first divide the number by 2 by using modulus operator ‘%’ and store the remainder in the array.
2 Step: divide that number by 2.
3 Step: Now repeat the step until the number is greater than 0.
Output:

2. Program to Convert Binary to Decimal in C++
In this program, we will convert the Binary input to Decimal.
Binary to Decimal Conversion Algorithm:
1 Step: Take a Binary Input to convert into Decimal.
2 Step: Multiply each binary digit starting from last with the power of 2 i.e(2^0,2^1).
3 Step: make an addition of the multiplied digits.
4 Step: Thus the addition gives the Decimal output.
Output:

3. Decimal to Binary Conversion Using Bitwise Operator
Output:

4. Decimal to Binary Without Using Array
Output:

Post a Comment