Write ONE C Program which has four functions and a main as described below: 1 5...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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? 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?
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Two-dimensional array operations: Movie Ratings program ** You have recently collected reviews from four movie reviewers where the reviewers are numbered 1-4. Each reviewer has rated six movies where...
-
As an employer, what are steps you can take to avoid discrimination litigation?
-
Suppose the random variable X has a geometric distribution with p _ 0.5. Determine the following probabilities: (a) P(X = 1) (b) P(X =4) (c) P(X =8) (d) P(X < 2) (e) P(X =2)
-
Ali, Bo, Cleo, and Dallas are picking their entrees at a restaurant. The choices are pasta, quesadillas, risotto, and sushi. They have some strict dietary preferences: Cleo will not order sushi. ...
-
What are some potential problems with low-carb diets?
-
Hearty Soup Co. uses a process cost system to record the costs of processing soup, which requires a series of three processes. Materials are entered at the beginning of the Filling process. The...
-
What processes were employed and why / how did they contribute to operating success for the case study?
-
Erica and Bob participate in a friendly Hackathon that allows each to solve one question a day out of the three offered. There will be one easy, one medium and one hard question, with points awarded...
-
Which of the following is an Agile way of working? Select the correct option(s) and click submit. Senior associates create plans and take decisions. Junior associates execute tasks Lead creates plans...
-
U.S. luxury retailer Neiman Marcus filed for Chapter 11 bankruptcy protection in May 2020. Its owners at the time were the Canada Pension Plan Investment Board (CPPIB) and Ares Management, who...
-
BNT Transportation is considering building a new facility to manufacture tugboats. If BNT builds the new plant, it will partially replace an existing plant that some in BNT management argue is...
-
Lucille has just purchased a call option on YYY Corp.Shares of YYY are trading at $20 each, and the exercise price on the call is $19.The option expires in 75 days and during this period, Lucille can...
-
Araba town council plans to build a bridge over the local river to replace the existing ferry service. Building will start in one year's time, that is 2006 and will take 4 yrs. It has planned to sub...
-
For the circuit shown in Figure 1, a) Find v and v. b) Find and 1 c) Find the power dissipated in the 12 52 and 40 52 resistors
-
What is the present value of $19,000 due 8 periods hence, discounted at 9%? (Round answer to O decimal places, e.g. 458,581.) Present value 2$
-
You deposit $10,000 in a savings account that earns 7.5% simple interest per year. What is the minimum number of years you must wait to double your balance? Suppose instead that you deposit the...
-
Show that the method of analysis of variance always produces unbiased point estimates of the variance components in any random or mixed model.
-
The tensile strength of portland cement is being studied. Four different mixing techniques can be used economically. The following data have been collected: (a) Test the hypothesis that mixing...
-
A rocket propellant manufacturer is studying the burning rate of propellant from three production processes. Four batches of propellant are randomly selected from the output of each process and three...
-
The times required by students to complete a statistics test. State whether the data described are discrete or continuous and explain why?
-
Number of cars crossing the Golden Gate Bridge each hour. State whether the data described are discrete or continuous and explain why?
-
The speeds of cars as they pass the center of the Golden Gate Bridge. State whether the data described are discrete or continuous and explain why?
Study smarter with the SolutionInn App