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
-
Respond to the scenario below with your thoughts, ideas, and comments. Be substantive and clear, and use research to reinforce your ideas. You and Shawn met yesterday with the members of a...
-
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...
-
The International Auditing and Assurance Standards Board (IAASB) recently revised its standards related to audit reporting. ISA 700 (Revised), Forming an Opinion and Reporting on Financial...
-
Classmates are discussing what happens to the chocolate chips and butter if the heating of the block is stopped at 5oC (41o F) and the ice is just barely melted but is still near freezing. Classmate...
-
Is flowcharting useful in analyzing the resources required to implement a system?
-
Youve recently learned that the company where you work is being sold for $275,000. The companys income statement indicates current profits of $10,000, which have yet to be paid out as dividends....
-
You have a potato gnocchi dish as a trial dish up on today's menu. Your selling price is at $21. Your food cost is laid out at 27%. 1.How much money have you spent in dollars for food cost? 2.What is...
-
David R. and Ella M. Cole (ages 39 and 38, respectively) are husband and wife who live at 1820 Elk Avenue, Denver, CO 80202. David is a self-employed consultant, specializing in retail management and...
-
Please make your commends for the following situations about the types of the vibration Dominantfrequenciesn your Transfer Function measuremerfrom your tool tip aregiven in Table2. (10 marks Modes...
-
A 6-digit PIN number is selected. What it the probability that there are no repeated digits? The probability that no numbers are repeated is Write your answer in decimal form, rounded to the nearest...
-
The programming language is Python im not sure which question is wrong is there any problem with my answers? Match the type of loop to its basic description. Prompts Submitted Answers A loop that...
-
On a separate piece of paper, place a "+" in front of the statements you personally agree with, a "-" in front of those you believe are not true for you, and leave blank those with which you neither...
-
A company has received a contract to supply cement to three new construction sites located in the cities A, B, C. Experts have estimated that the amount of cement which will be required at the three...
-
Verde Custom Cabinets issued $3,200 and $5,400 of direct materials into production for Jobs ABX and DFY, respectively. Direct labor of $2,300 was distributed to Job ABX and $3,400 to Job DFY. Factory...
-
Bill wants to explore factors affecting work stress. He would like to examine the relationship between age, number of years at the workplace, perceived social support, and work stress. He collects...
-
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...
-
Explain how a monopolist determines its price and output.
-
Describe and explain why marginal revenue is less than price in the monopoly model.
-
Define monopoly.
Study smarter with the SolutionInn App