Homework Assignment 6 COP 3223C Building and Working with Simple Linked Lists

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (3 votes)

Write a program in C that does the following:
a) Builds a simple linked list consisting of 10 nodes each of which contains a random integer
between 50 and 100 inclusive. The list is to be built in main() and must be a local variable
in main().
b) Includes a user-defined function named printout(arg) that takes in the head pointer of
the already-built linked list as an argument and prints out the contents of the linked list to
the screen, starting from the head of the list to the tail. See the output below.
Node #0 contains 53
Node #1 contains 78
Node #2 contains 95
.
.
.
Node #20 contains 100
c) Includes a user-defined function called sum() that adds up the contents of the data
members of each node in the list, and prints out the total as follows:
The sum total of all nodes in this list is
d) Includes a user-defined function called reverse() that takes in the head pointer of the
already-built linked list as an argument and will physically reverse the order of the nodes in
the list (i.e., the new head will be the old tail and the new tail will be the old head of the
list). Use the function printout() to output its contents now in reverse order. This does
NOT mean that it will be read backwards, but rather, the reversed list will be read from
head to tail!