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?



how to set Nth bit of a variable?..

Answer / 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

More C Interview Questions

What is an volatile variable?

15 Answers   HP,


How do you determine a file’s attributes?

0 Answers  


Is it possible to use curly brackets ({}) to enclose single line code in c program?

0 Answers  


Why c is a procedural language?

0 Answers  


What is chain pointer in c?

0 Answers  


What is sizeof in c?

0 Answers  


What is use of integral promotions in c?

0 Answers  


What is the difference between formatted&unformatted i/o functions?

0 Answers  


What are derived data types in c?

0 Answers  


How do I create a directory? How do I remove a directory (and its contents)?

0 Answers  


struct node {struct node*temp,*new} prinf("%d",sizeof(struct node));

2 Answers  


What are the uses of pre-processor directives?

2 Answers  


Categories