Here is source code of the C Program to check if a given bit position is set to one or not. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Check if a given Bit Position is set to One or not
unsigned int number;
int result, position;
printf("Enter the unsigned integer:\n");
printf("enter position to be searched\n");
result = (number >> (position));
if (result & 1)
$ cc bit14.c $ a.out Enter the unsigned integer: 128 enter position to be searched 7 TRUE
Sanfoundry Global Education & Learning Series – 1000 C Programs.