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

What do you know about the use of bit field?

1099


Is c easier than java?

1124


How can you allocate arrays or structures bigger than 64K?

1200


Explain the use of 'auto' keyword in c programming?

1184


can any one provide me the notes of data structure for ignou cs-62 paper

2231


How can I run c program?

1232


Why c is called top down?

1217


What is the difference between text files and binary files?

1397


Write the syntax and purpose of a switch statement in C.

1151


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1188


What does %c mean in c?

1139


What are the 3 types of structures?

1064


What is the scope of global variable in c?

1036


What is the difference between null pointer and wild pointer?

1249


How variables are declared in c?

1100