subject

Bitwise operations in c. write a c program which will either set or clear a single bit in a number entered by the user using the binary representation of the number. the user should input the original integer value between 1 and 1000 inclusive using a scanf. use an unsigned integer type. output is to the screen. you must use only bitwise operators for this program. you can shift bits and or use the logical bitwise operators. for this assignment give the user directions asking them to enter the integer and then ask the user if he or she wants to clear or set a bit. then ask the user which bit to set or clear. that can be a number between 0 and 31. prompt the user for what should be entered each time. be sure to validate all user input so the program cannot be crashed. after completing the operation ask the user if they want to do the entire operation again. the user would enter y or y to do it again. this would be the entire operation from entering the first integer.•if the user enters a 1 as the initial value and a 0 for the bit to clear the result would be 0.•if the user enters a 1 as the initial value and a 0 for the bit to set the result would be 1.•if the user enters a 10as the initial value and a 1 for the bit to clear then the result would be 8.•if the user enters a 10 as the initial value and a 1 for the bit to set then the result would be 10.•if the user enters a 10 as the initial value and a 2for the bit to clear then the result would be 10.•if the user enters a 10 as the initial value and a 2 for the bit to set then the result would be 14.output for each operation should be easy to read giving the number before the switch and then the decimal number after the switch. no other output should be included.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:00
Suppose an astronomer discovers a large, spherical-shaped body orbiting the sun. the body is composed mostly of rock, and there are no other bodies sharing its orbit. what is the best way to categorize this body? a. planet b. moon c. comet d. asteroid
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
If an improvement creates no significant change in a product’s performance, then it is a(n) ? a0 design improvement. (there are no answer choices)
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
Is an attack that relies on guessing the isns of tcp packets
Answers: 2
question
Computers and Technology, 23.06.2019 03:10
Fill in the following program so that it will correctly calculate the price of the orange juice the user is buying based on the buy one get one sale.#include //main functionint main() { int cartons; float price, total; //prompt user for input information printf("what is the cost of one container of oj in dollars? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & price); printf("how many containers are you buying? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & cartons); if ( [ select ] ["cartons / 2", "cartons % 1", "cartons % 2", "cartons % price", "cartons / price", "cartons / total"] [ select ] ["=", "==", "! =", "< =", "> =", "< "] 0) total = [ select ] ["price * cartons", "cartons * price / 2 + price", "(cartons / 2) * price", "cartons / (2.0 * price)", "(cartons / 2.0) * price + price", "((cartons / 2) * price) + price"] ; else total = ((cartons / 2) * price) + price; printf("the total cost is $%.2f.\n", total); return 0; }
Answers: 2
You know the right answer?
Bitwise operations in c. write a c program which will either set or clear a single bit in a number e...
Questions
question
Mathematics, 13.04.2021 17:50
question
Social Studies, 13.04.2021 17:50
question
Physics, 13.04.2021 17:50
question
Mathematics, 13.04.2021 17:50
question
Mathematics, 13.04.2021 17:50
Questions on the website: 13722367