# C C++ program to convert decimal to binary

## C C++ program to convert decimal to binary

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP

### C program to convert decimal to binary

``````#include<stdio.h>
int main()
{
int decimal, binary=0, digit, base=1;
printf("Enter decimal number: ");
scanf("%d",&decimal);
while(decimal!=0)
{
digit=decimal%2;
binary=digit*base+binary;
base=base*10;
decimal=decimal/2;
}
printf("Binary number = %d",binary);
return 0;
}``````

### C++ program to convert decimal to binary

``````#include<iostream>
using namespace std;
int main()
{
int decimal, binary=0, digit, base=1;
cout<<"Enter decimal number: ";
cin>>decimal;
while(decimal!=0)
{
digit=decimal%2;
binary=digit*base+binary;
base=base*10;
decimal=decimal/2;
}
cout<<"Binary number = "<<binary;
return 0;
}``````

### Output of C C++ program to convert decimal to binary

```Enter decimal number: 52
Binary number = 110100```
```Enter decimal number: 78
Binary number = 1001110 ```

Share it to: