-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path138.c
More file actions
50 lines (42 loc) · 622 Bytes
/
138.c
File metadata and controls
50 lines (42 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//dynamic bit check karnya sathi
#include<stdio.h>
#include<stdbool.h>
typedef int BOOL;
BOOL ChkBit(unsigned int iNo,int iPos)
{
if(iPos<1||iPos>32)
{
return false;
}
unsigned int iMask=0x00000001;
iMask=iMask<<(iPos-1);
unsigned int Result=0;
Result=iNo & iMask;
if(Result==iMask)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
unsigned int iValue;
int iRet=0,iPos=0;
printf("Enter number\n");
scanf("%u",&iValue);
printf("enter the bit\n");
scanf("%d",&iPos);
iRet=ChkBit(iValue,iPos);
if(iRet==true)
{
printf("Bit is on\n");
}
else
{
printf("Bit is off\n");
}
return 0;
}