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 you read a directory in a C program?
Write a program to print "hello world" without using a semicolon?
how to create duplicate link list using C???
What is the purpose of the statement: strcat (S2, S1)?
What is methods in c?
What is typedef?
What is || operator and how does it function in a program?
What is table lookup in c?
Is c is a high level language?
Explain the difference between ++u and u++?
Are comments included during the compilation stage and placed in the EXE file as well?
What is typedef example?
What does %c mean in c?
What is main () in c language?
Without Computer networks, Computers will be half the use. Comment.