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

Is null a keyword in c?

1194


What is the difference between volatile and const volatile?

983


What is local and global variable in c?

1196


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1734


Explain what are multibyte characters?

1188


In C language what is a 'dangling pointer'?

1138


What is merge sort in c?

1046


What does 3 mean in texting?

1094


What are nested functions in c?

1015


What are local static variables?

1150


Explain what is wrong in this statement?

1119


What is string function in c?

983


Lists the benefits of c programming language?

1138


If null and 0 are equivalent as null pointer constants, which should I use?

1214


What are the disadvantages of external storage class?

1054