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
What is meant by inheritance?
What is meant by initialization and how we initialize a variable?
What is main return c?
Explain what does it mean when a pointer is used in an if statement?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
How can I direct output to the printer?
what are bit fields? What is the use of bit fields in a structure declaration?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
Explain how can type-insensitive macros be created?
What kind of structure is a house?
Write a program to generate the Fibinocci Series
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?
Can a program have two main functions?
What is structure pointer in c?