C program to convert decimal to binary: c language code to convert an integer from decimal number system(base-10) to binary number system(base-2). Size of integer is assumed to be 32 bits. We use bitwise operators to perform the desired task.
Here you will get all programs of C JAVA etc.As the name of blog suggest it is new level or you can say high level programming. Here all the programs are other than syllabus and somewhat crazy stuff. So enjoy implementing the codes and feedback us in the feedback form.
#include <stdio.h> int main() { int n, c, k; printf("Enter an integer in decimal number system\n"); scanf("%d", &n); printf("%d in binary number system is:\n", n); for (c = 31; c >= 0; c--) { k = n >> c; if (k & 1) printf("1"); else printf("0"); } printf("\n"); return 0; }
Run the code and enjoy :)
No comments:
Post a Comment