diff --git a/C/program-55/program.c b/C/program-55/program.c new file mode 100644 index 00000000..ff134113 --- /dev/null +++ b/C/program-55/program.c @@ -0,0 +1,22 @@ +/* Program that prints a number in binary*/ + +// start writng code from here +#include + +int main (void) +{ + int b; + unsigned int mask = 1<<31; + + printf("Input a 32bits integer number: "); + scanf("%d", &b); + + while (mask != 0){ + printf("%d", b&mask?1:0); + mask >>= 1; + } + + printf("\n"); + + return 0; +} diff --git a/C/program-55/read.md b/C/program-55/read.md new file mode 100644 index 00000000..42d8c087 --- /dev/null +++ b/C/program-55/read.md @@ -0,0 +1,4 @@ +# program-55 +## Program that prints a number in binary + +This program uses bitwise operators to print a 32bits integer in binary representation