how to TOGGLE Nth bit of variable in a MACRO



how to TOGGLE Nth bit of variable in a MACRO..

Answer / kiran kumar yakkala

#define ~toggle(val,n) var^=1<<n


Is This Answer Correct ?    8 Yes 2 No

Post New Answer

More C Interview Questions

What is getch() function?

0 Answers  


what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);

10 Answers   IBM,


if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order?

4 Answers   Amazon, Apple, Bata, Google, NASA,


Difference between C and Embedded C?

1 Answers  


I didn't count the ducks that I saw in line, but I do remember that one duck was in front of two ducks, another duck behind two ducks. How many ducks did I see?

2 Answers  


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

0 Answers  


Result of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a)0,5,9,13,17 b)5,9,13,17 c)12,17,22 d)16,21 e)syntax error

8 Answers   IBM,


what is the associativity of bitwise OR operator?

1 Answers  


what is an ERP?

2 Answers   Infotech,


what is dangling pointer?

1 Answers   LG Soft,


what do you mean by enumeration constant?

0 Answers  


what will be maximum number of comparisons when number of elements are given?

0 Answers  


Categories