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
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
Write a program for finding factorial of a number.
Write a code to generate divisors of an integer?
How many data structures are there in c?
Explain what are reserved words?
write a program to print data of 5 five students with structures?
How to delete a node from linked list w/o using collectons?
How can a program be made to print the name of a source file where an error occurs?
Why is c called c not d or e?
swap 2 numbers without using third variable?
Why C language is a procedural language?
Why is c used in embedded systems?
Explain how can I pad a string to a known length?
What are global variables and explain how do you declare them?