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
Can a program have two main functions?
List out few of the applications that make use of Multilinked Structures?
Can we use any name in place of argv and argc as command line arguments?
Write a program to implement queue.
How can you read a directory in a C program?
using for loop sum 2 number of any 4 digit number in c language
What is #define?
What are types of structure?
Discuss the function of conditional operator, size of operator and comma operator with examples.
How do you convert strings to numbers in C?
What are the advantages of Macro over function?
formula to convert 2500mmh2o into m3/hr
How can I call fortran?
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..
What does main () mean in c?