1#include <stdio.h>
2void binary(unsigned n)
3{
4 unsigned i;
5 for (i = 1 << 31; i > 0; i >>= 1)
6 (n & i)? printf("1"): printf("0");
7}
8int main()
9{
10 int i;
11 printf("Enter The Number : ");
12 scanf("%d", &i);
13 binary(i);
14 printf("\n");
15 return 0;
16}
1//Java Solution for Decimal To Binary Conversion
2
3import java.util.*;
4public class DecimalToBinary {
5
6 public static void main(String[] args) {
7 // TODO Auto-generated method stub
8 Scanner sc = new Scanner(System.in);
9 int dec = sc.nextInt();
10 StringBuffer sb = new StringBuffer();
11 while(dec!=0)
12 {
13 sb.append(dec%2);
14 dec=dec/2;
15 }
16 System.out.println(sb.reverse());
17
18 }
19
20}
21