### Overview:

As we know that time is the most important concern in our life. To do any task easily, We have to use software to perform it in a simpler manner. Software is a set of programs with related documents. The Software Program or Program is a set of instructions to do a specific task. First, of all, I want to explain What is Number System? Then, I will explain What is a Decimal Number? Furthermore, I will explain What is a Binary Number? After that, I will write the logic for conversion between Decimal to Binary numbers as a C Program.

### Table of contents:

- What is a Number System?
- What is a Decimal Number?
- What is a Binary Number?
- What is a Program?
- Demonstration of Conversion between Decimal to Binary Number.
- C Program to convert Decimal to Binary Number.
- Explanation of Decimal to Binary Number Program with output.

### What is a Number System?

**Number System** is a system that is used to represent a number. There are mainly four types of Number System in computers such as Decimal Number System, Binary Number System, Octal Number System, and Hexa- Decimal Number System. Each Number System uses its own digits to represent a number. The repetition of digits does not matter. For instance, a Decimal Number System uses 10 digits i.e. 0,1,2,3,4,5,6,7,8,9 to represent a number. A Binary Number System uses 2 digits i.e. 1, 0 to represent a number, etc.

### What is a Decimal Number?

A **Decimal Number** System used to represent a Decimal Number. We can say that the **radix or base** of a Decimal Number System is **10**. A Decimal Number is constructed with any digit from 0 to 9. A **Decimal Number** looks like a Mathematical number. For instance, 24 is a Decimal Number constructed from the digits 2 and 4. Furthermore, Decimal Number is a combination of any digits i.e. **0,1,2,3,4,5,6,7,8,9**. There are various examples of Decimal numbers such as 124, 179, 111, 1245, etc.

### What is a Binary Number?

A **Binary Number** System used to represent a Binary Number. We can say that the **radix or base** of a Binary Number System is **2**. A Binary Number is constructed with digits 0 and 1. A Computer can understand only binary language that is a mixture of Binary numbers. For instance, 11000 is a Binary Number constructed from the digits **1 and 0** which is the value of a Decimal Number 24. Moreover, 10, 11, 100, 101 are examples of the Binary NUmber.

### What is a Program?

A **Program** is a set of instructions to perform a specific task. A Program tells the Computer What to do? And a Logic tells the computer How to do it? To Write a Program We will construct our own logic related to the task.

### Demonstration of Conversion between Decimal to Binary Number.

**Step 1:**Divide the Decimal number by 2 and store the remainder in an array.**Step 2:**Repeat Step 1 with the previous Quotient obtained by it until the 1.**Step 3:**At last Write the stored value of the array in reverse order to found the Binary Value.

**Example:** Conversion of Decimal Number 24 to Binary Number that is 11000.

Quotient | Quotient/2 | Remainder Array |
---|---|---|

Step 1: Divide the given Decimal number by 2 and store the remainder into a remainder array. | 24/2 | 0 |

Step 2: Repeat Step 1 because Quotient is not 1 | 12/2 | 0 |

Step 3: Repeat Step 1 because Quotient is not 1 | 6/2 | 0 |

Step 4: Repeat Step 1 because Quotient is not 1 | 3/2 | 1 |

Step 3: Don't Repeat again Step 1 because Quotient is 1 | 1 | 1 |

Now, Array values are 0,0,0,1,1. Write the array values in descending order to show the binary value of 24 i.e. 11000.

### C Program that will convert the Entered Decimal Number to Binary Number.

#include <stdio.h> #include <stdlib.h> void main() { int r[10], decimal_Number, q; system ("cls"); printf("Please! Enter the Decimal number to convert into Binary Number: "); scanf("%d",&decimal_Number); for(q=0; decimal_Number>0; q++) { r[q]=decimal_Number%2; decimal_Number=decimal_Number/2; } printf("Binary equivalent of Entered Decimal Number is:"); for(q=q-1;q>=0;q--) { printf("%d",r[q]); } }

Save this program with the filename and extension .c like filename.c. Then compile it on turbo C or another compiler.

**The output of the program looks like this:**

*Please! Enter the Decimal number to convert into Binary Number:* 24

*Binary equivalent of Entered Decimal Number is:* 11000

**Conclusion:** Explanation of This Program with output. The internal working of this program depends upon the previous demonstration of Conversion between Decimal to Binary Number.

After the successful compilation of the program, a message is displayed on the screen as Please! Enter the Decimal number to convert into Binary Number: Suppose, User entered 24 then again a message is displayed as Binary equivalent of Entered Decimal Number is: 11000 with Binary equivalent of 24 i.e. 11000.