write a c program to change only the 3rd bit of the
particular number such that other bits are not affected..
if bitnum=10(say.. it can be any no..
Answer Posted / vadivel t
assume int holds 4bytes...
For ex:
#include <stdio.h>
int main()
{
int i = 16;
if(i & 0x04)
{
/*3rd bit is set to 1- so reset it to 0 - other bits will
not be disturbed*/
i = i & 0xFFFFFFFFB;
printf("IN IF \n");
}
else
{
/*3rd bit is set to 0- So set it to 1 - other bits will
not be disturbed*/
i = i | 0x00000004;
}
printf("%d", i);
_getch();
return 0;
}
Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
How can I recover the file name given an open stream?
Why should I use standard library functions instead of writing my own?
shorting algorithmS
c language interview questions & answer
What are the differences between new and malloc in C?
What are the characteristics of arrays in c?
Differentiate between static and dynamic modeling.
Can you add pointers together? Why would you?
When is a “switch” statement preferable over an “if” statement?
What would be an example of a structure analogous to structure c?
Is python a c language?
Explain 'far' and 'near' pointers in c.
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
What does 3 periods mean in texting?
What is difference between union and structure in c?