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
What are the 3 types of structures?
What is equivalent to ++i+++j?
Why string is used in c?
Explain 'bus error'?
What do you know about the use of bit field?
When was c language developed?
Is c high or low level?
What is sizeof return in c?
What is typedf?
Difference between constant pointer and pointer to a constant.
What does do in c?
What is storage class?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
What do you mean by recursion in c?
How can I manipulate individual bits?