COMP 206 Software Systems Mini Assignment #5 Solved

30.00 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (2 votes)

Linked Lists and Modular Programming


This assignment explores malloc, makefile, modular programming, and git.


The central problem you will solve is a linked-list like the one shown in the lecture slides. You do not need to use the lecture slides.


Construct a modular program from three sources files: main.c, list.c and list.h.  The file main.c will be used to call the functions provided by the file list.c.  The file list.c builds a private linkedlist within the list.c named space.  The file list.h contains the definition of the list’s node structure. Use #ifndef to protect the possible multiple inclusion of list.h, as we talked about in class.


Use a makefile to compile your assignment. Use git to version control the development of your assignment. To prove that you used a makefile submit your makefile file. To prove that you used git, save the output from git log into a text file and submit that file.


The program will run as follows:

  • The main() function uses a while loop accepting only positive integer numbers (n>0) from the user. The loop terminates once the user enters a non-positive value. The user is prompted for each number one at a time.
  • In the loop, main() calls functions from the list.o named space that creates a private linked list using malloc.
  • The following function signatures are supported by list.c:
    • void newList();
      • This function assumes there is a private global linked-list pointer in list.c called head that is used to point to the beginning of a linked-list. This function call simply initializes this pointer to NULL.
    • int addNode(int value);
      • This function mallocs a new node and copies the parameter value into the node. This function then adds the node to the head of the linked-list.  The function ends by returning true for success and false for failure. A node has the following structure: struct NODE { int data; struct NODE *next; }.
    • void prettyPrint();
      • This function assumes a global pointer called head exists. Using this head pointer is traverses the linked-list printing all the values stored in the list.
    • When the loop terminates the program prints to screen all the numbers in the list. The output should be in reverse order.
    • The program then terminates.
    • Do NOT use recursion.