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
Is null a keyword in c?
What is the difference between volatile and const volatile?
What is local and global variable in c?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
Explain what are multibyte characters?
In C language what is a 'dangling pointer'?
What is merge sort in c?
What does 3 mean in texting?
What are nested functions in c?
What are local static variables?
Explain what is wrong in this statement?
What is string function in c?
Lists the benefits of c programming language?
If null and 0 are equivalent as null pointer constants, which should I use?
What are the disadvantages of external storage class?