Given a number (int a = 0XABCDE98)
I am trying to set the D
bit to 6
.
ie after the Bit manipulation the number should be (0XABC6E98)
.
I have written a small C program to do the bit manipulation, but somehow I am not able to see the correct bit change. Please help me in finding what might be missing in the program.
#include<stdio.h>
int main()
{
int n = 0xABCDE98;
n |= (n & 0X0000) | 0x6000;
printf("%x\n", n);
return 0;
}
o/p - abcfe98
Change:
to:
or just:
if you prefer.
Test:
Compile and run:
LIVE CODE