b. (10 points) In this part you will flesh out the definition of a C function...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
b. (10 points) In this part you will flesh out the definition of a C function zeroOutByte whose specification is given in the comment above the code skeleton below. the Bits • This is like one of the functions from your Bits assignment. However, unlike assignment, in this problem you must *not* use any C implementation to test your work. • You must follow all of the rules from the bits assignment in your code - i.e., no literal constants larger than one byte are allowed; no use of the Ob notation; no helper functions; no use of control constructs such as if, do, while, for, switch; no use of any operators other than the ones explicitly listed as legal in the function description; etc. • Strive to make the definition of your function as clear as possible. It's a good idea to de- compose your function by introducing well-named local variables, each of which does some small amount of work. Use comments to explain aspects that are nonobvious. /* * zeroOutByte: between 0 (LSB) and 3 (MSB), inclusive. * Assume n is byte number * zeroOutByte (x, n) returns an integer that is a version of x * in which the the nth byte has been replaced by 0x00. * *For example: zeroOutByte (0x12345678, 0) should return Ox12345600 zeroOutByte (0x12345678, 1) should return Ox12340078 zeroOutByte (0x12345678, 2) should return 0x12005678 zeroOutByte (0x12345678, 3) should return 0x00345678 * * * * EX * ak */ Legal ops: ! ~ & ˆ | + << >> Max ops: no limit int zeroOutByte (int x, int n) { b. (10 points) In this part you will flesh out the definition of a C function zeroOutByte whose specification is given in the comment above the code skeleton below. the Bits • This is like one of the functions from your Bits assignment. However, unlike assignment, in this problem you must *not* use any C implementation to test your work. • You must follow all of the rules from the bits assignment in your code - i.e., no literal constants larger than one byte are allowed; no use of the Ob notation; no helper functions; no use of control constructs such as if, do, while, for, switch; no use of any operators other than the ones explicitly listed as legal in the function description; etc. • Strive to make the definition of your function as clear as possible. It's a good idea to de- compose your function by introducing well-named local variables, each of which does some small amount of work. Use comments to explain aspects that are nonobvious. /* * zeroOutByte: between 0 (LSB) and 3 (MSB), inclusive. * Assume n is byte number * zeroOutByte (x, n) returns an integer that is a version of x * in which the the nth byte has been replaced by 0x00. * *For example: zeroOutByte (0x12345678, 0) should return Ox12345600 zeroOutByte (0x12345678, 1) should return Ox12340078 zeroOutByte (0x12345678, 2) should return 0x12005678 zeroOutByte (0x12345678, 3) should return 0x00345678 * * * * EX * ak */ Legal ops: ! ~ & ˆ | + << >> Max ops: no limit int zeroOutByte (int x, int n) {
Expert Answer:
Answer rating: 100% (QA)
The goal of the zeroOutByte function is to replace a specific byte in an integer x with 0x00 The byte to be replaced is determined by the input parame... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
24. A group of statements to be executed a whole are enclosed in: braces {} parentheses () bracket [] any of the above will work to indicate a grouping . b. C. d. 25. What class is used to display...
-
24. A group of statements to be executed a whole are enclosed in: braces {} parentheses () bracket [] any of the above will work to indicate a grouping . b. C. d. 25. What class is used to display...
-
A group of statements that executes as a unit is a _____________. a. Block b. Family c. Chunk d. Cohort
-
Which is not a difference between a limited liability company and a limited liability partnership? a. An LLC, unlike an LLP or LLLP, can exist with only one owner. b. All members of an LLC have...
-
The true value of one type of degree or diploma cannot be quantitatively measured, but we can measure its relative impact on starting salary. Graduates from Quebec universities with a B.A. or a B.Sc....
-
In a substitution reaction, C8H9Br, a compound that contains a phenyl group, reacts with NaSH with H2O being the solvent. The original compound has placed the leaving group, Br, on an in plane bond....
-
Presented below are selected financial data from the The Coca-Cola Company 2015 annual report. Using the ratio definitions from Exhibit 4.6, calculate the following ratios: receivable turnover,...
-
The temperature in a process unit is controlled by passing cooling water at a measured rate through a jacket that encloses the unit. The exact relationship between the unit temperature T(?C) and the...
-
Explain the bioethical issue of cloning within a healthcare facility. Identify and evaluate the bioethical healthcare issue of cloning facing healthcare administrators. Discuss how they would...
-
Newlyweds Jamie Lee and Ross have had several milestones in the past year. They are newly married, recently purchased their first home, and now have twins on the way! Jamie Lee and Ross have to...
-
THE TIME Complexity AND SPACE Complexity FOR THIS CODE IS 1 for (int i=0; i
-
1. what is influencer marketing and its growing importance in the digital era? 2. summary of the new influencer marketing law in France and its concepts and theories 3. Discuss how the law can be...
-
What components do you review and are critical that go into assumptions of next period operations?
-
Consider a real-time system with the following task set: Task 1: C-4, T-8 Task 2: C-3, T-12 Task 3: C-2, T-20 where C is the computation time and T is the period. Assume periods and deadlines are the...
-
In the month of March, Green Meteor Co. had the following inventory information and transactions: March 1 Beginning Inv. 200 Units @ $70 per unit March 2 Purchased 84 Units @$65 per unit March 31...
-
What skill do you think HR managers and line managers need to develop in order to deal with conflict in the workplace ?
-
Question 2 Discuss the banks position in each of the following situations and state what actions you will take: a) i. B.A Samuelson had maintained an account with you for 3 years. He has been a...
-
Which of the companies has the lowest accounts receivable turnover in the year 20X2? a. Company A. b. Company B. c. Company C. d. CompanyD. 20X1 20X2 Credit Sales Average Receivables Balance $1.0...
-
Draw a structured flowchart or write structured pseudocode describing how to buy a new shirt. Include at least two decisions and two loops.
-
When you write the declaration for a method that can receive a parameter, which of the following must be included in the method declaration? a. The name of the argument that will be used to call the...
-
Create the logic for the dice game Pig, in which a player can compete with the computer. The object of the game is to be the first to score 100 points. The user and computer take turns rolling a pair...
-
If information systems auditors perform a staff function, which of the following aspects of leadership is likely to be most difficult to accomplish? a. Motivating information systems auditors to...
-
Which of the following is least likely to be a purpose of a yearly staff appraisal meeting conducted between an information systems auditor and his/her manager? a. To determine the interpersonal...
-
Which of the following is least likely to be a reason why the career paths available to information systems auditors are often limited? a. Many organizations have only a few information systems audit...
Study smarter with the SolutionInn App