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
-
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...
-
Skold Company produces slacks. Materials for the slacks are dyed in large vats. After dyeing the materials for a given colour, the vats must be cleaned and prepared for the next batch of materials to...
-
On January 1, 2020, the accounting records of Sasseville Lte included a debit balance of $15 million in the building account and of $12 million in the related accumulated depreciation account. The...
-
Crush Autosmashers can purchase a new electromagnet for moving cars at a cost of \($20,000.\) At the end of its useful life, the electromagnet will be worth \($1,000.\) If Crushs MARR is 12...
-
Hawthorn Corporations adjusted trial balance contained the following accounts at December 31, 2012: Retained Earnings $120,000; Common Stock $750,000; Bonds Payable $100,000; Paid-in Capital in...
-
IQ scores (as measured by the Stanford-Binet intelligence test) are normally distributed with a mean of 100 and a standard deviation of 16. What percentage of the population has an IQ score between...
-
The Philbrick Company has two plants on opposite sides of the United States. Each of these plants produces the same two products and then sells them to wholesalers within its half of the country. The...
-
XYZ Company has a capital structure consisting of 60% equity and 40% debt. The cost of equity is 10%, and the pre-tax cost of debt is 7%. The company's tax rate is 25%. What is the company's weighted...
-
The ratio that indicates the percentage of each sales dollar available to cover the fixed costs and to provide operating income is termed the contribution margin ratio. Group of answer choices True...
-
Which statement is TRUE for not-for-profit organizations? Not-for-profit corporations are subject to double taxation Not-for-profits are generally exempt from all levels of property, income, and...
-
Are there any financial projections one might make about the district? (Huntley distrirct 158)
-
Asset classes such as fixed income, equity, derivative. what are the strengths and weaknesses?
-
Institutional investors include Blank______. (Select all that apply.) Multiple select question. venture capitalists pension funds mutual funds charitable foundations
-
The difference between the yields of long-term bonds and the yields of short-term bonds issued by the same corporation at the same time is usually caused by the difference in maturities (maturity...
-
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...
-
In small groups, discuss the worst or most difficult interview questions you have ever received. Add to your list by searching the internet for weird or unusual questions. Review your list and...
-
Research a geographic area where you would like to work. Investigate the cost of living, industrial growth in the area, weather and climate, and attractions in the area you could visit. The local...
-
The required rate of return is 12%, and the expected rate of inflation over the life of the project is forecast to remain steady at 3%. Should you invest in this project?
Study smarter with the SolutionInn App