Question: Write ONE C Program which has four functions and a main as described below: 1 5 9 1. (10 Points) A function called funl
Write ONE C Program which has four functions and a main as described below: 1 5 9 1. (10 Points) A function called funl that takes as input a 2 D matrix of integer values, the number of rows, and number of columns of the matrix, and returns the product (multiplication) of all the elements of the matrix. 2. (10 Points) A function called fun2 that takes as input a 2 D matrix of integer values, the number of rows, and number of columns of the matrix, and returns in a ID array the sum of each row in the matrix. 3. (15 Points) A function called fun3 that takes as input a 2 D matrix of integer values, the number of rows, and number of columns of the matrix, and returns the number of Even Numbers in the matrix. 4. (15 Points) A function called fun4 that takes as input a 2 D matrix of integer values, the number of rows, and number of columns of the matrix, and prints all the elements in the matrix in zigzag form. Example of zigzag printing of a matrix: 2 6 10 3 7 11 8 12 ZigZag print: 1, 2, 3, 4, 8, 7, 6, 5, 9, 10, 11, 12 5. (20 Points) A main where you declare a 2D matrix called A with the following initialization: A[4][4] = {{10, 20, 30, 44), (44,5), (65, 57), and then test functions fun1, fun2, fun3, fun4 using the A matrix and show the output of each function call. PART B - Software Engineering (30 points) Answer the following questions: 1) (10 Points) What is the advantage of using functions in a C program compared to writing everything in the main? [justify and give examples from your code in part A] 2) (10 Points) What is the difference between a pass by value and a pass by reference? [justify and give examples from your code in part A] 3) (10 Points) When passing an array to a function, are modifications done to the array in the function reflected in the main? How can you prevent a function from changing the values of an array?
Step by Step Solution
3.40 Rating (147 Votes )
There are 3 Steps involved in it
include Function to calculate the product of all elements in the matrix int fun1int matrix4 int rows int cols int product 1 for int i 0 i rows i for int j 0 j cols j product matrixij return product Fu... View full answer
Get step-by-step solutions from verified subject matter experts
