I\'m writing a function to print bits in c, I\'m only allowed to use write function. my function doesn\'t work for other numbers.
write
void print_bit
If you want to print bits then used bitwise operator and you can do that...
such example:
for(i=31 ; i>=0 ; i--) { if(num & 1<< i) /* num & 1 << position printf("1 "); else printf("0 "); } printf("\n");