how to set Nth bit of variable by using MACRO
Answer Posted / vikram
The above code is wrong it should be n-1 instead of n.
#include<stdio.h>
#define SET(val,n) (val|=1<<(n-1))
main()
{
int n = 256;
printf("%d",SET(n,1));
}
Is This Answer Correct ? | 13 Yes | 8 No |
Post New Answer View All Answers
Explain how can I make sure that my program is the only one accessing a file?
diff between exptected result and requirement?
What is masking?
How can I find the modification date and time of a file?
How many types of functions are there in c?
How will you delete a node in DLL?
What are the different file extensions involved when programming in C?
What does 1f stand for?
Place the #include statement must be written in the program?
What is a const pointer?
How can I generate floating-point random numbers?
Difference between exit() and _exit() function?
Explain the use of 'auto' keyword
Is c object oriented?
What is a ternary operator in c?