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 to set Nth bit of variable by using MACRO

Answer Posted / sunitha

/* macro to set Nth bit */

#define SET_N_BIT(x,n) x|((~(unsigned)0)>>(8-(n-n-1))<<n);

Try out this . this is optimised version for setting a bit
work for any bit upto 8 bits if u want for 32 bits than
replace 8 with 32.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of keyword 'register' with respect to variables.

1019


What is methods in c?

1081


What are nested functions in c?

1011


Write a program to reverse a given number in c language?

1108


What are global variables and how do you declare them?

1087


What is meant by int main ()?

1200


What is gets() function?

1119


what are the advantages of a macro over a function?

1138


How can you find the exact size of a data type in c?

999


What does 3 mean in texting?

1092


How is pointer initialized in c?

1019


why we wont use '&' sing in aceesing the string using scanf

2367


Sir i need notes for structure,functions,pointers in c language can you help me please

2405


Write programs for String Reversal & Palindrome check

1054


What are enums in c?

1196