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...

write a c program to change only the 3rd bit of the
particular number such that other bits are not affected..
if bitnum=10(say.. it can be any no..

Answer Posted / binu

YOU CAN SET OR CLEAR THE THIRD BIT without changing other bits

#define BIT3 (0X01<<3)
void main()
{
int a;
//set the third bit of a
a|=BIT3;
//clear the third bit
a&=~BIT3;

Is This Answer Correct ?    11 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you have any idea how to compare array with pointer in c?

987


What is the difference between class and object in c?

1086


What is the correct code to have following output in c using nested for loop?

1025


Write a program of advanced Fibonacci series.

1092


Is c procedural or object oriented?

952


What is sizeof c?

1001


What do mean by network ?

1098


What are the different data types in C?

1146


Explain what are the advantages and disadvantages of a heap?

1029


Can a pointer point to null?

1019


How does free() know explain how much memory to release?

1011


State two uses of pointers in C?

1008


What is pointer in c?

1140


Why is main function so important?

1046


What is a macro, and explain how do you use it?

1015