Programming Applications for Engineers
P a g e | 1
Programming Applications for Engineers
CS 159 (Summer 2 - 2020)
Weekly Assessment 3 - (15%)
Individual submission: Upload a clear version of your answers to
Moodle.
Student name:……………….. Student ID:……………………
1. Name the .c file with your ID number. Mention your name, ID as comments at top of
code.
2. Each weekly assessment can be submitted twice within the deadline.
3. Strictly, the submission file type should be .c file.
4. Weekly Assessment submission deadline is 13/09/2020 @23:59. A delay in
assessment submission will result in the following grade deduction
· Delay of 1 Day : 10% Deduction
· Delay of 2 Days: 20% Deduction
· Delay of 3 Days: 40% Deduction
· Delay of 4 Days: 50% Deduction
· Delay of 5 Days: 100% Deduction
5. In case of plagiarized submission, student will receive a notification email with the
below penalty applied starting the date of the email:
· Resubmission on the first day (within 24 hours after notification): 20%
deduction
· Resubmission on the second day after notification: 30% deduction
· Resubmission on the third day after notification: 50% deduction
· Failing to resubmit within three days after notification, the assessment will be
graded with zero
6. Please check Banner for your Gradebook and Attendance.
7. AUM rules and regulations apply.
P a g e | 2
Problem
Create a C program which calculates the evaluation points of participants in a competition. The
program should take the ratings given by the participants for each other and perform several
evaluations. The program design should use main and the below functions. Note that you need
to use at least one nested loop in the body of each function.
Consider the constant SIZE with value equal to 5 and a two-dimensional array of size: SIZE x SIZE
called rate_participant, that represents rating points among participants. The participant
ID is equal to the value of the index in the array rate_participant. For example, the first
row in the array (index = 0) represents the points given from participant with ID = 0 to all other
participants (ID=0, ID= 1, ID=2 and ID=3).
Part 1
1. Define a function O_Highest_6 that accepts a 2D array rate_participant and a 2D
array called high, which represents each rater ID and rated participant ID with the
highest rate. The function finds the highest rate each participant has given to all other
participants and stores the rater participant ID and rated participant ID in array high as
shown in the example below. The array high should have 2 columns to store the rater
ID and the rated ID. (20 points)
Participant 0 Participant 1 Participant 2 Participant 3 Participant 4
Participant 0 25 50 75 100 125
Participant 1 50 25 75 100 125
Participant 2 50 75 25 100 125
Participant 3 50 75 100 25 125
Participant 4 50 75 100 125 25
rate_participant
Rater ID Rated ID
0 4
1 4
2 4
3 4
4 3
high
Part 2
2. Define a function O_Sum_6 that accepts a 2D array rate_participant and a one-
dimensional array sum_rate of size equal to SIZE as formal parameters. The function
calculates the sum points each participant has received from all other participants and stores
them in sum_rate. (20 points)
P a g e | 3
3. Define a function O_Display_6 that accepts rate_participant and sum_rate as
formal parameters and displays all arrays’ elements as shown in the sample output below. It
also finds and displays who won the competition. (20 points)
4. Define a function O_Student_6 that displays your name, your CS 159 section number and your
ID on the screen as shown below. (20 points)
Figure 1. Student’s information.
5. Write a main function that performs the following: (20 points)
Define and initialize the following arrays: rate_participant, high and sum_rate
with 0.
Prompt the user to fill the array rate_participant with points entered by other
participants based on their performance: 50, 75, 100, 125 (from the Worst to the Best)
-Note that the participants cannot rate themselves. Their points should be set to 25 by
default. Also, they cannot rate two participants with the same point.
Display the sample output by calling the following functions: O_Sum_6, O_Display_6 and
O_Student_6
P a g e | 4
Sample Output: