Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How we can set and clear bit in a byte using macro function?

Answer Posted / c.p.senthil

#define SETBIT(num,bitpos) (num|(1<<bitpos))
#define CLRBIT(num,bitpos) (num&(~(1<<bitpos)))

int a = 0x03; // a = 00000011b = 0x03(3)
SETBIT(a, 3); // a = 00001011b [3rd bit set] = 0x0b(11)

int b = 0x25; // b = 00100101b = 0x25(37)
CLRBIT(b, 2); // b = 00100001b [2nd bit clear] = 0x21(33)

Is This Answer Correct ?    27 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a program flowchart and explain how does it help in writing a program?

1312


Explain Basic concepts of C language?

1161


How to Throw some light on the splay trees?

1066


Why we use break in c?

1014


What math functions are available for integers? For floating point?

1138


What does sizeof int return?

1083


Apart from dennis ritchie who the other person who contributed in design of c language.

1402


What is the g value paradox?

1173


What is volatile keyword in c?

1037


What does c mean?

1052


What is the difference between void main and main in c?

1156


write a program to rearrange the array such way that all even elements should come first and next come odd

2279


How can you increase the size of a statically allocated array?

1081


Ow can I insert or delete a line (or record) in the middle of a file?

1005


What is sizeof return in c?

1039