programming-examples/c/Bitwise/C Program to Check if a given Bit Position is set to One or not.c

19 lines
443 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C Program to Check if a given Bit Position is set to One or not
*/
#include <stdio.h>
void main()
{
unsigned int number;
int result, position;
printf("Enter the unsigned integer:\n");
scanf("%d", &number);
printf("enter position to be searched\n");
scanf("%d", &position);
result = (number >> (position));
if (result & 1)
printf("TRUE\n");
else
printf("FALSE\n");
}