# Program to convert a decimal number to Binary

### Code:

#include <stdio.h>
#include <math.h>
int
main ()
{
int decimal;
printf ("Enter a Decimal Number: ");
scanf ("%d", &decimal);

int binary = 0;
int reminder, temp = 1;

while (decimal != 0)
{
reminder = decimal % 2;
decimal = decimal / 2;
binary = binary + reminder * temp;
temp = temp * 10;
}

printf ("The Binary Number is: %d", binary);
return 0;
}

Input/Output:
Enter a Decimal Number:
67
The Binary Number is: 1000011

### Code:

#include <iostream>
using namespace std;
int
main ()
{
int decimal;
cout<<"Enter a Decimal Number: ";
cin>>decimal;

int binary = 0;
int reminder, temp = 1;

while (decimal != 0)
{
reminder = decimal % 2;
decimal = decimal / 2;
binary = binary + reminder * temp;
temp = temp * 10;
}

cout<<"The Binary Number is: "<<binary;
return 0;
}

Input/Output:
Enter a Decimal Number: 205
The Binary Number is: 11001101

### Code:

import java.util.Scanner;
public class DecimalToBinary {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int decimal;
System.out.println("Enter a Decimal Number: ");
decimal=cs.nextInt();

int binary = 0;
int reminder, temp = 1;

while (decimal != 0)
{
reminder = decimal % 2;
decimal = decimal / 2;
binary = binary + reminder * temp;
temp = temp * 10;
}

System.out.println("The Binary Number is: "+ binary);
cs.close();
}
}

Input/Output:
Enter a Decimal Number:
78
The Binary Number is: 1001110

### Code:

print("Enter a Decimal Number: ")
decimal=int(input())
binary = 0
temp = 1
while (decimal != 0):
reminder = decimal % 2
decimal = decimal // 2
binary =int (binary + (reminder * temp))
temp =int( temp * 10)

print("The Binary Number is: ",binary)

Input/Output:
Enter a Decimal Number:
5
The Binary Number is:  101