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 c token?
Explain built-in function?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
How can you check to see whether a symbol is defined?
Do you know the difference between malloc() and calloc() function?
Write a program for finding factorial of a number.
write a program to display all prime numbers
Simplify the program segment if X = B then C ← true else C ← false
What is New modifiers?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
Write a program to swap two numbers without using a temporary variable?
What is the purpose of the statement: strcat (S2, S1)?
about c language
What is the difference between functions abs() and fabs()?
What is the difference between a function and a method in c?