Assignment 21
`
CE264 Advanced C Programming Page 1 of 2
Assessment 1 (10%) Semester : Fall Year : 2020 Course Title :
Advanced C Programming Course Code : CE264 Instructor(s) : Dr. Rita Ammanouil, Dr. Pierre E. ABI-CHAR. (Includes names of all instructors teaching this course)
To be completed by the student Student Name : Student ID : Section :
Grading Scheme Question Earned Points Max. Points Question Earned Points Max. Points
1 70 6
2 30 7
3 8 4 9 5
10
Total Earned Points Total Available Points Instructor Signature
Assessment Regulations:
- Print this template and write your answers for each problem in the space given. Handwriting is acceptable.
- Make sure to answer all questions. - Pay attention whenever you have “Show your work” or “show all step” - Total number of pages: 2 - Scan the template after you provide your answers. - Upload the scanned template on Moodle in your section page. Do not upload on the Meta -course
`
CE264 Advanced C Programming Page 2 of 2
PART A – Programming (70 points)
Write ONE C Program which has four functions and a main as described below:
1. (10 Points) A function called fun1 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 1D 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:
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?
P.S: You should submit your answers to PART A as a .C file, and your answers to PART B as a word document.
1 2 3 4
5 6 7 8
9 10 11 12