First name Date: January 8th, 2024 Second name No electronic equipment (calculators, phones etc.) are allowed!...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
First name Date: January 8th, 2024 Second name No electronic equipment (calculators, phones etc.) are allowed! Functions from the standard libraries can be used. 1. Simulate the execution of the following program fragment; r is the array of int; Index grows from left to right. Initial value of x: 0 1 2 3 4 Code: for(i=0; i<5; i++) { x[i] = x [x[i]]); Fill the boxes with final values of x after the code execution: } 2. a) Design a Commodity structure to store information about an article in the supermarket. The structure should include: product name, product code (digits only), price, quantity in stock (number of boxes). Use the best-suited data type for each piece of information. Oranges; 10394901; 3.99; 100 Apples; 40209492; 2.56; 40 b) Write CommCmp function that takes two Commodity structures as parameters and compares them. First, we compare the prices, and when the comparison will not determine the result (both are equal), we compare the product names. During strings comparison, we check the alphabetical order. During strings comparison, we check the alphabetical order. Hint: you can use function from the standard library to compare the strings. The CommCmp function returns: :: -1 if the first structure is "smaller" than the second; :: 0 if both structures are equal; :: 1 if the first structure is “greater than the second; c) The information about all the commodities in stock is stored in the file. The size of the file, as well as the number of records, is unknown. The exemplary structure of the file is as follows: Particular entries are separated with a semicolon. Write the CommFromFile function, that reads the contents of the file into the array of Commodity. Dynamic memory allocation is appreciated. Handle potential errors. First name Date: January 8th, 2024 Second name No electronic equipment (calculators, phones etc.) are allowed! Functions from the standard libraries can be used. 1. Simulate the execution of the following program fragment; r is the array of int; Index grows from left to right. Initial value of x: 0 1 2 3 4 Code: for(i=0; i<5; i++) { x[i] = x [x[i]]); Fill the boxes with final values of x after the code execution: } 2. a) Design a Commodity structure to store information about an article in the supermarket. The structure should include: product name, product code (digits only), price, quantity in stock (number of boxes). Use the best-suited data type for each piece of information. Oranges; 10394901; 3.99; 100 Apples; 40209492; 2.56; 40 b) Write CommCmp function that takes two Commodity structures as parameters and compares them. First, we compare the prices, and when the comparison will not determine the result (both are equal), we compare the product names. During strings comparison, we check the alphabetical order. During strings comparison, we check the alphabetical order. Hint: you can use function from the standard library to compare the strings. The CommCmp function returns: :: -1 if the first structure is "smaller" than the second; :: 0 if both structures are equal; :: 1 if the first structure is “greater than the second; c) The information about all the commodities in stock is stored in the file. The size of the file, as well as the number of records, is unknown. The exemplary structure of the file is as follows: Particular entries are separated with a semicolon. Write the CommFromFile function, that reads the contents of the file into the array of Commodity. Dynamic memory allocation is appreciated. Handle potential errors.
Expert Answer:
Answer rating: 100% (QA)
The execution of the given program fragment will result in the array x having the same values at all ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Visit one of the following websites, or locate other websites that help you create a chart or graph: Beam Chart Maker ( beam.venngage.com ), Canva ( canva.com/graphs/ ), Charts Builder (...
-
The main reason for this forum is to allow you the space to expand your comprehension of target market segmentation. To complete this forum you'll respond to three critical thinking scenarios. Pick a...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The formula for the power output P of a battery is P = VI - RI where V is the electromotive force in volts, R is the resistance in ohms, and I is the current in amperes. Find the current that...
-
Paul and Sonja, who are married, had itemized deductions of $8,200 and $400, respectively, during 2016. Paul suggests that they file separately-he will itemize his deductions from AGI, and she will...
-
The inventory account of Vanda Manufacturing Co. includes raw materials and work in process and is on a perpetual inventory basis using the FIFO costing method. There is no finished goods inventory....
-
The following information was taken from the financial statements of Flexcor Corporation on December 31 of the current year. The comparative income statement of Flexcor Corporation reveals the...
-
You have been asked to comment on the covering letter that Zaid prepared. What are your suggestions to improve this covering letter? As an overseas student, Zaid Kilani chose to research downsizing...
-
Consider the below partial code of an XML document. Write the beginning of this XML document, including the XML declaration and the DTD. Your DTD will allow for more than one participant within a...
-
Complete a failure mode effect analysis for the nitric acid plant reactor section described in Example 9.2. (This is best carried out as a group activity with a group size of three to six). Data from...
-
Compare Amazon's annual cash flows for the most recent 3 year period (2020-2022) and make a "general" statement about where the cash comes from and where it goes. Select one or two significant...
-
Do you agree with this argument? Why or why not? Argument against position: The ability to purchase guns should never be restricted, because they protect people. Validity: Potentially invalid, as it...
-
Explain what is meant by Customer Lifetime Value. How do marketers apply this formula to determine the effectiveness of their direct marketing programs? What are some advantages and disadvantages to...
-
Exercise 1-14B Interpreting information shown in a balance sheet Both balance sheets shown in the following table were dated as of December 31, Year 3: Balance Sheets for Assets Cash Land Total...
-
Cramton and Dees discuss an imaginary country, Metopia, to discuss deception in negotiation. They offer advice and thoughts on promoting honesty in negotiations, and on page 13 of the article,...
-
Coburn (beginning capital, $57,000) and Webb (beginning capital $92,000) are partners. During 2022, the partnership earned net income of $65,000, and Coburn made drawings of $14,000 while Webb made...
-
14. Find f(t) if f '(t)=ti+ =j+tek and f (0)=i+2j +3k. 1+t
-
Quality Chicken grows and processes chickens. Each chicken is disassembled into five main parts. Information pertaining to production in July 2012 is: Joint cost of production in July 2012 was $50. A...
-
Clarita is a single taxpayer with two dependent children, ages 10 and 12. Clarita pays $3,000 in qualified child care expenses during the year. If her adjusted gross income (all from wages) for the...
-
Kent Pham, CPA, is a 45-year-old single taxpayer living at 169 Trendie Street, La Jolla, CA 92037. His Social Security number is 865-68-9635. In 2012, Kent's W-2 as the controller of a local...
-
Bill and Guilda each own 50 percent of the stock of Radiata Corporation, an S corporation. Guilda's basis in her stock is $25,000. On July 31, 2012, Bill sells his stock, with a basis of $40,000, to...
-
Department 2 of Kapp Company has a gross profit of \($100,000,\) representing 40% of net departmental sales. Traceable departmental expenses are \($75,000.\) Management believes that an increase of...
-
Department A of Racine Company has a gross profit of \($140,000,\) representing 35% of net departmental sales. Management believes that an increase of \($36,000\) in advertising will increase volume...
-
What is the maximum amount that one division should pay to another division of the same company for a component needed in manufacturing its product?
Study smarter with the SolutionInn App