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

void toggle_kth_bit_IMPROVED(int *n, int bitToBeChanged)
{
*n=*n^(1<<(bitToBeChanged-1));
}

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 4 types of functions?

1061


Explain indirection?

1147


Is there anything like an ifdef for typedefs?

1156


What is struct node in c?

1081


Describe explain how arrays can be passed to a user defined function

1114


Is it better to use a macro or a function?

1167


How can you find out how much memory is available?

1073


What is the difference between ++a and a++?

1221


When do we get logical errors?

1132


Explain about C function prototype?

1103


Explain the concept and use of type void.

1119


Is it better to use malloc() or calloc()?

1122


How can I make sure that my program is the only one accessing a file?

1283


Write a program to print ASCII code for a given digit.

1101


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

3073