C Programming Code Examples C > Bitwise Operators Code Examples convert decimal to binary number system using bitwise operator convert decimal to binary number system using bitwise operator Write a C program to input any decimal number from user and convert it to binary number system using bitwise operator. How to convert from decimal number system to binary number system using bitwise operator in C programming. Input a decimal number from user. Store it in some variable say j. Declare an array of size required to store an integer in memory (i.e. 32 bits), say bin[INT_SIZE];. Initialize another variable to store index, say index = INT_SIZE - 1;. Run a loop from INT_SIZE to 0. Inside the loop assign Least Significant Bit to bin[index]. Perform bin[index] = j & 1;. Decrement index by 1 and right shift j by 1. #include <stdio.h> #define INT_SIZE sizeof(int) * 8 /* Size of int in bits */ int main() { int j, index, i; int bin[INT_SIZE]; /* Input number from user */ printf("Enter any number: "); scanf("%d", &j); index = INT_SIZE - 1; while(index >= 0) { /* Store LSB of j to bin */ bin[index] = j & 1; /* Decrement index */ index--; /* Right Shift j by 1 */ j >>= 1; } /* Print converted binary */ printf("Converted binary: "); for(i=0; i<INT_SIZE; i++) { printf("%d", bin[i]); } return 0; }