The following code has been written to find out and display the maximum value in each...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The following code has been written to find out and display the maximum value in each column of a matrix: 1. 2. 3. { 4. int m[4] [2], i, j, colMax [2] ; 5. 6. 7. 8. 9. 10. 11. (a) #include "mbed.h" int main () (b) 12. 13. } 14. } (c) /* Read elements of the matrix */ for (i=0; i<4; i++) for(j=0; j<2; j++) scanf("%d", &m[i][j]); /* find and display the max value in each column */ for (i=0; i<2; i++) colMax [i] = m[i] [0]; for(j=0; j<2; j++) (d) { for (i=1; i<4; i++) if (colMax [j] > m[i][j]) colMax [j] = m[i][j]; printf ("max value in column %d = %d\n", j, colMax [j]); The code contains TWO errors. Identify them, copy the following table to your answer sheet and use it to answer the question. Correction Line Error Rewrite the code using two functions: One function to read the matrix elements using pointers; and Another function to find out and display the maximum value in each column using arrays as the formal parameters. (5 marks) Show how the two functions can be called from the main function. (2 marks) ● ● Draw the structure chart. (2 marks) main (1 mark) The following code has been written to find out and display the maximum value in each column of a matrix: 1. 2. 3. { 4. int m[4] [2], i, j, colMax [2] ; 5. 6. 7. 8. 9. 10. 11. (a) #include "mbed.h" int main () (b) 12. 13. } 14. } (c) /* Read elements of the matrix */ for (i=0; i<4; i++) for(j=0; j<2; j++) scanf("%d", &m[i][j]); /* find and display the max value in each column */ for (i=0; i<2; i++) colMax [i] = m[i] [0]; for(j=0; j<2; j++) (d) { for (i=1; i<4; i++) if (colMax [j] > m[i][j]) colMax [j] = m[i][j]; printf ("max value in column %d = %d\n", j, colMax [j]); The code contains TWO errors. Identify them, copy the following table to your answer sheet and use it to answer the question. Correction Line Error Rewrite the code using two functions: One function to read the matrix elements using pointers; and Another function to find out and display the maximum value in each column using arrays as the formal parameters. (5 marks) Show how the two functions can be called from the main function. (2 marks) ● ● Draw the structure chart. (2 marks) main (1 mark)
Expert Answer:
Answer rating: 100% (QA)
a Identifying and Correcting Errors 1 The first error is in line 5 where the scanf function is used ... 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
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
If the focal length of a lens is 3 centimeters and the image distance is 5 centimeters from the lens, what is the distance from the object to the lens?
-
If the Federal Government increases taxes:What will be the effect on money demand, money supply, and interest rates? Money demand decreases, money supply is unchanged, and interest rates decrease...
-
Describe the connection between testing truth and following spiritual authority. Use the four-step methodology of understanding, analysis, evaluation and application. You may use the Bible for...
-
Marti decides to keep placing a $1 bet on number 15 in consecutive spins of a roulette wheel until she wins. On any spin, theres a 1-in-38 chance that the ball will land in the 15 slot. a. How many...
-
True or False: The following annual cash flows in years 1 thru 7, respectively, have a single real positive-valued root: \(-\$ 100,+\$ 15,-\$ 25,+\$ 75,-\$ 10,+\$ 50\), \(+\$ 50\).
-
Treatment of Various Costs Allegro Supply Company, a newly formed corporation, incurred the following expenditures related to Land, to Buildings, and to Machinery and Equipment. Determine the amounts...
-
A summary of two stocks is shown. 52W high 52W low Name of Stock Symbol High Low Close 37.18 29.39 Zycodec ZYO 11.76 7.89 Unix Co UNX 39.06 32.73 34.95 16.12 12.11 15.78 Last year, a stockholder...
-
Funtime, Inc., manufactures video game machines. Market saturation and technological innovations caused pricing pressures that resulted in declining profits. To stem the slide in profits until new...
-
A rectangular specimen of an alloy (150 mm x 200 mm) has been subjected to cold working treatment to increase its strength. The dimensions of the specimen after deformation became (100 mm x L mm). i....
-
Say that the hourly cost to employers per German industrial worker is $43. The hourly cost to employers per U.S. industrial worker is $39, while the average cost per Taiwanese industrial worker is...
-
Theres a gas shortage in Gasland. Youre presented with two proposals that will achieve the same level of reduction in the use of gas. Proposal A would force everybody to reduce their gas consumption...
-
If you are willing to pay $5,000 for a used car that is a cherry and $1,000 for a used car that is a lemon, how much will you be willing to offer to purchase a car if there is a 50 percent chance...
-
Suppose an air-quality law is passed that requires 3.75 percent of all the cars sold to emit zero pollution. a. What would be the likely impact of this law? b. Can you think of any way in which this...
-
In his book At the Hand of Man, Raymond Bonner argues that Africa should promote hunting, charging large fees for permits to kill animals (for example, $7,500 for a permit to shoot an elephant). a....
-
Outline some classroom rules, consequences and rewards you might plan to use in the coming year. Are these different from those you already have in place this year?
-
If a and b are positive numbers, find the maximum value of f ( x ) = x a (9 x ) b on the interval 0 x 9.
-
Steve Jackson (age 51) is a single taxpayer living at 3215 Pacific Dr., Del Mar, CA 92014. His Social Security number is 465-88-9415. In 2012, Steve's earnings and income tax withholding as the...
-
Laura is a single taxpayer living in New Jersey with adjusted gross income for the 2012 tax year of $35,550. Laura's employer withheld $3,300 in state income tax from her salary. In April of 2012,...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Consider the data file mroz on working wives and the model \(\ln (W A G E)=\beta_{1}+\beta_{2} E D U C+\) \(\beta_{3} E X P E R+e\). Use the 428 observations on married women who participate in the...
-
Using the data from Table 2, construct a \(95 \%\) confidence interval estimate of the mean difference, \(\mu_{d}\). By Hand Approach Step 1 Compute the differenced data. Because the sample size is...
-
Problem Decide whether the sampling method is independent or dependent. Then determine whether the response variable is qualitative or quantitative. (a) Joliet Junior College decided to implement a...
Study smarter with the SolutionInn App