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

Toggle nth bit in a given integer - num

Answer Posted / vadivel t

#include<stdio.h>

int main()
{
int no, bit;
printf("ENTER THE NO AND BIT NO, TO TOGGLE: ");
scanf("%d %d", &
no, &bit);
if(no & (0x1 << bit-1))
{
no = no^(0x1 << bit - 1);
}
else
{
no = no | (0x1 << bit - 1);
}
printf("%d \n", no);

_getch();
}

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are near, far and huge pointers?

1012


What is the purpose of realloc()?

1093


What is difference between array and structure in c?

1089


Explain how many levels deep can include files be nested?

1024


Where are local variables stored in c?

980


Can you please compare array with pointer?

1024


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

1140


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

2243


Why use int main instead of void main?

1068


What is structure in c definition?

982


Explain union.

1110


What is c basic?

1120


Why doesn't C support function overloading?

2601


Is there sort function in c?

965


What is the need of structure in c?

1046