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 / ajay karanam

int main()
{
int number=0;
int bitTobeChanged=0;
int endResult=0;

printf("Enter the number\n");
scanf("%d",&number);

printf("Enter the bit to be changed\n");
scanf("%d",&bitTobeChanged);

endResult=number|(0x1<<(bitTobeChanged-1));

printf("End Result = %d\n",endResult);

return 0;
}

Is This Answer Correct ?    18 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does 3 periods mean in texting?

1075


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

1112


What does node * mean?

1250


What does 2n 4c mean?

1243


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1960


There seem to be a few missing operators ..

1054


What is difference between array and pointer in c?

1101


What is keyword in c?

1019


What is ambagious result in C? explain with an example.

2642


Explain what is the difference between far and near ?

1116


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3252


What is a char c?

1049


What's a good way to check for "close enough" floating-point equality?

1174


With the help of using classes, write a program to add two numbers.

1049


how can f be used for both float and double arguments in printf? Are not they different types?

1079