1: #include <stdio.h>
2:
3: int main()
4: {
5: int i;
6: scanf("%d",&i);
7: while(i--)
8: {
9:
10: int n, c, k;
11:
12: printf("Enter an integer in decimal number system\n");
13: scanf("%d", &n);
14:
15: printf("%d in binary number system is:\n", n);
16:
17: for (c = 31; c >= 0; c--)
18: {
19: k = n >> c;
20:
21: if (k & 1)
22: printf("1");
23: else
24: printf("0");
25: }
26:
27: printf("\n");
28:
29: }
30: return 0;
31: }
Tuesday, March 1, 2016
Decimel to Binary in C
Labels:
C Programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thank you for commenting. Please wait for response :)