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
Explain how do you list files in a directory?
What is malloc calloc and realloc in c?
Are there constructors in c?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
Is stack a keyword in c?
What is the purpose of & in scanf?
What is c language used for?
Explain what are compound statements?
What does %p mean?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
write a c program in such a way that if we enter the today date the output should be next day's date.
Define Array of pointers.
what will be the output for the following main() { printf("hi" "hello"); }
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
What is #include stdio h?