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
What was noalias and what ever happened to it?
What is the most efficient way to store flag values?
How do I get an accurate error status return from system on ms-dos?
I need a sort of an approximate strcmp routine?
What is a static variable in c?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
What is the basic structure of c?
Is file a keyword in c?
How can I get back to the interactive keyboard if stdin is redirected?
What is struct node in c?
Explain pointer. What are function pointers in C?
What is null in c?
what is uses of .net
What is the difference between malloc() and calloc() function in c language?
What are the features of c languages?