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 are qualifiers and modifiers c?
What is a class c rental property?
Describe the modifier in c?
What are the rules for identifiers in c?
Explain main function in c?
How are pointers declared in c?
What is your stream meaning?
What is default value of global variable in c?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
Can you please explain the difference between strcpy() and memcpy() function?
What is the equivalent code of the following statement in WHILE LOOP format?
Can the “if” function be used in comparing strings?
What is a file descriptor in c?
What are the advantage of c language?
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }