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...
-
Show how Petrochemical Parfum can also use futures contracts to protect itself against a rise in the price of crude oil. Show how the payoffs would vary if the oil price is $80, $90, or $100 a...
-
(a) In Figure 4.3, which box of popcorn first shows diminished marginal utility? (i) Total utility (ii) Marginal utility (b) In the cartoon "You can have too much of a good thing," which pizza slice...
-
Two conspirators, Timothy Carpenter and Timothy Sanders, were charged with aiding and abetting a robbery affecting interstate commerce and the use or carriage of a firearm. At trial, the FBI...
-
Change in Estimate Depreciation Thurber Co. purchased equipment for $710,000 which was estimated to have a useful life of 10 years with a salvage value of $10,000 at the end of that time....
-
Ruler Formula Bar Normal Page Break Page Custom Preview Layout Views Gridlines Headings Zoom 100% Zoom To Selection Window Macros Workbook Views Show Zoom Macros A A1 V A B D E F G H 4 Assume That...
-
An individuals income varies with his or her age. The following table shows the median income I of males of different age groups within the United States for 2006. For each age group, let the class...
-
A new sports car shown in Figure 2 was tested and it was able to accelerate from rest to 100 km/h in 1.75 seconds. The diameter of the tyres are 720mm. Assuming no slippage occurs between the wheels...
-
A company will make the following annual lease lease i payments over the course of a 3-year" $150, $190 $160. Rent expense in the first year? (straight-line depreciation method) A company buys a $48...
-
write a thesis for my Family Law class the topic is Divorce and the paper has to be 10 pages ?
-
How can data analytics, sentiment analysis, and social network analysis be utilized to measure the effectiveness of communication strategies, track audience engagement, and inform iterative...
-
A firm uses 50 percent common stock, 40 percent debt, and 10 percent preferred stock. the cost of equity is 14 percent, the cost of preferred is 12 percent, and the pre-tax cost of debt is 7 percent....
-
How can psychological resilience interventions, such as mindfulness-based stress reduction programs, cognitive-behavioral therapy techniques, and resilience training workshops, empower individuals to...
-
MIPS is an architecture having its own Assembly Language. You are learning x86 assembly Language. Differentiate between Assembly Language of Both types of Architecture in terms of the followings 1)...
-
Suppose that you could invest in the following projects but have only $30,000 to invest. How would you make your decision and which projects would you invest in? Project Cost $ 8,000 11,000 9,000...
-
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...
-
A child receives \($100\),000 as a gift, which is deposited in a bank account earning 6 percent compounded semiannually. If \($5\),000 is withdrawn at the end of each half year, how long will the...
-
The plan was to leave $5,000 on deposit in a savings account for 15 years at 6.5 percent interest compounded annually. It became necessary to withdraw $1,500 at the end of the fifth year. How much...
-
A deposit of $3,000 is made in a savings account that pays 7.5 percent interest compounded annually. How much money will be available to the depositor at the end of 16 years? a. $8,877 b. $10,258 c....
Study smarter with the SolutionInn App