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 / ajay karanam
int main()
{
int number=0;
int bitTobeChanged=0;
int endResult=0;
printf("Enter the number\n");
scanf("%d",&number);
printf("Enter the bit to be changed\n");
scanf("%d",&bitTobeChanged);
endResult=number|(0x1<<(bitTobeChanged-1));
printf("End Result = %d\n",endResult);
return 0;
}
| Is This Answer Correct ? | 18 Yes | 10 No |
Post New Answer View All Answers
What does 3 periods mean in texting?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
What does node * mean?
What does 2n 4c mean?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
There seem to be a few missing operators ..
What is difference between array and pointer in c?
What is keyword in c?
What is ambagious result in C? explain with an example.
Explain what is the difference between far and near ?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
What is a char c?
What's a good way to check for "close enough" floating-point equality?
With the help of using classes, write a program to add two numbers.
how can f be used for both float and double arguments in printf? Are not they different types?