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 a variable?

Answer Posted / kirankumaryakkala

ex: int res=16, temp=1,n;
printf("enter the Nth bit no");
scanf("%d",&n);
temp=temp<<n; //leftshift to ntimes
res=res|temp; //bitwise OR
printf("setted nth bit of res %d",res);

Is This Answer Correct ?    9 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If the size of int data type is two bytes, what is the range of signed int data type?

1021


What is the use of printf() and scanf() functions?

1128


Write a program to reverse a given number in c?

1037


Why is structure important for a child?

1099


Explain how can I write functions that take a variable number of arguments?

1076


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1269


What is the use of #define preprocessor in c?

1074


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

2636


What is the use of linkage in c language?

1056


Can you assign a different address to an array tag?

1167


Explain what is the difference between the expression '++a' and 'a++'?

1214


What is function and its example?

1209


What are the 3 types of structures?

1029


Explain what are header files and explain what are its uses in c programming?

1154


Is it fine to write void main () or main () in c?

1025