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

Write a program to identify if a given binary tree is balanced or not.

684


what value is returned to operating system after program execution?

1606


What is the general form of #line preprocessor?

587


What does sizeof return c?

605


Can a local variable be volatile in c?

575






What are pointers really good for, anyway?

617


What is #include cctype?

580


What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

677


What are keywords c?

603


How can I remove the trailing spaces from a string?

616


What is a char c?

592


Whats s or c mean?

593


How can I get random integers in a certain range?

613


Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.

1593


What is a class c rental property?

614