Assignment Instructions
-
Edit, compile, and run the following program on the UH UNIX shell:
-
Insert 25 to 75 random integers from 0 to 100 into a linked list.
-
Write a function "sum()" that returns the sum of the integers in the list by looping through the linked list.
-
Write a function "count()" that counts the number of nodes in the list by looping through the linked list.
-
Use the two functions to calculate the floating point average of the elements.
-
Email your makefile and C program to the instructor, or show it to the instructor in class.
-
For the submission guidelines and the grading guidelines, see the syllabus.
Example I/O
The list is: 0, 0, 1, 4, 5, 6, 8, 9, 12, 13, 14, 17, 19, 20, 20, 23, 24, 25, 25, 26, 28, 30, 30, 32, 34, 36, 37, 38, 43, 44, 46, 50, 53, 54, 54, 62, 62, 65, 66, 66, 68, 70, 70, 74, 79, 79, 80, 82, 83, 85, 85, 89, 96, 97,
sum = 2338
count = 54
average = 43.30
The list is: 1, 2, 7, 9, 15, 17, 17, 18, 18, 19, 19, 19, 20, 22, 22, 22, 22, 25, 26, 27, 27, 27, 30, 31, 35, 36, 37, 39, 40, 41, 43, 44, 47, 48, 49, 49, 52, 54, 55, 58, 58, 58, 59, 61, 61, 62, 65, 72, 74, 75, 84, 85, 85, 85, 86, 86, 86, 88, 89, 89, 90, 91, 92, 93, 95, 96, 97,
sum = 3351
count = 67
average = 50.01
The list is: 1, 2, 4, 10, 12, 22, 22, 23, 23, 23, 28, 38, 42, 47, 47, 48, 49, 60, 65, 65, 66, 67, 78, 79, 80, 80, 82, 86, 90, 94, 97,
sum = 1530
count = 31
average = 49.35