how to set Nth bit of variable by using MACRO
Answer Posted / sunitha
/* macro to set Nth bit */
#define SET_N_BIT(x,n) x|((~(unsigned)0)>>(8-(n-n-1))<<n);
Try out this . this is optimised version for setting a bit
work for any bit upto 8 bits if u want for 32 bits than
replace 8 with 32.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Differentiate call by value and call by reference?
what is recursion in C
Which programming language is best for getting job 2020?
How do you use a pointer to a function?
How many levels of indirection in pointers can you have in a single declaration?
What is a structural principle?
what is use of malloc and calloc?
What are dangling pointers in c?
Why is it important to memset a variable, immediately after allocating memory to it ?
I heard that you have to include stdio.h before calling printf. Why?
What are the advantages and disadvantages of c language?
What are 'near' and 'far' pointers?
What is binary tree in c?
Why c is a mother language?
What are the 5 organizational structures?