Write a C program to run on ocelot which will either set or clear a single...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C program to run on ocelot 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. You do not need to use getopt for this program since there are no command line arguments. 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 10 as 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 2 for 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. The program should compile to create an executable called bitops. Write a C program to run on ocelot 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. You do not need to use getopt for this program since there are no command line arguments. 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 10 as 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 2 for 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. The program should compile to create an executable called bitops.
Expert Answer:
Related Book For
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell
Posted Date:
Students also viewed these programming questions
-
In this question assume that p and q are atomic formulae. (a) Compare and contrast path formulae and state formulae in temporal logic. [4 marks] (b) Describe and contrast the meanings of F(G p) and...
-
A regular language is a language that can be defined by a regular expression. 0 2 . 1 Complete the unshaded cells of Table 1 to show which of the statements about regular languages are true and which...
-
Find the slopes of the curves at the given points. Sketch the curves along with their tangents at these points. r = sin 2; = /4, 3/4
-
Two first-order spectrum lines are measured by a 9650-slit/cm spectroscope at angles, on each side of center, of +26o38', +41 o 03' and -26 o 18', -41 o 27'. Calculate the wavelengths based on these...
-
The University of Wisconsin employs 200 teaching assistants (TAs). If one-third of the TAs sign a petition calling for a collective bargaining election, an election will be held. A survey of 50 TAs...
-
Consider the fuel consumption data in Table B.18. Regressor \(x_{1}\) is an indicator variable. Perform a thorough analysis of these data. What conclusions do you draw from this analysis? y X2 X3 X4...
-
What were your impressions of Kubricks interpretation of the Cold war in the film Clip Dr. Strangelove? Explain the paradoxical quote There is no fighting in the War Room
-
Question: Christian Volhard works as a financial analyst for Tooele Company, which operates a large chain of fast-food restaurants. One of the key costs of the fast-food restaurants is the cost of...
-
For each of the following three employees calculate gross earnings, CPP contributions, EI premiums, income taxes, and net pay after these statutory withholdings. All employees are in British...
-
Which of the following events occurring after the issuance of a set of financial statements and the accompanying auditors report would be most likely to cause the auditor to make further inquiries...
-
Now express some views about either absolute return or over/under performance. Given those views, find the adjusted return of each asset class and the recommended portfolio allocation.
-
Critics have charged that compensation to top managers in the banking sector is simply too high and should be cut back. Look at the financial accounts of some banks in your region and determine the...
-
What is a scatter diagram? Briefly explain the concept of a regression line in the context of a scatter diagram.
-
Do you think establishing a code of ethics is sufficient to ensure ethical behavior in an organization? What other forms of action or behavior might be necessary to ensure ethical business behavior?
-
Which analytical techniques should be used in a complete financial statement analysis?
-
Anderson, Rivera, and Turner are attempting to form a partnership to operate a public relations agency. They have agreed to share profits in a ratio of 4:3:3 but cannot settle on the terms of the...
-
The column shown in the figure is fixed at the base and free at the upper end. A compressive load P acts at the top of the column with an eccentricity e from the axis of the column. Beginning with...
-
If the msg variable contains the string Happy holidays, what will the location = msg.find("Day", 0); statement assign to the location variable? a. 1 b. 0 c. 10 d. 11
-
Follow the instructions for starting C++ and viewing the SwatTheBugs26.cpp file, which is contained in either the Cpp8\Chap09\SwatTheBugs26 Project folder or the Cpp8\Chap09 folder. (Depending on...
-
Create a program that displays the weekly gross pay for any number of employees. The user will input the number of hours the employee worked and the employees hourly rate. Employees working more than...
-
Eq. 7.36a is written for the conservation of momentum in y direction. Obtain Eq. 7.36-b wherein the stream function is independent variable. Eq. 7.36(a,b) y - v v +(1-y/R)v- + momentum: u u R-y + R P...
-
Show that the derivative of the boundary layer edge velocity is given by Eq. 7.64 for the figure given below. Eq. 7.64 M>>1 Ue dx R dy/dx = 1/R
-
Using Maslen method, find the approximate value of pressure and density at the junction of the sphere and the cone of Problem 7.29 at Mach number 8. Problem 7.29 An empirical way to determine shock...
Study smarter with the SolutionInn App