Programming Project # 1

(due Wed April 9)

This an exercise using Call by Reference and String Processing, and Linked Lists.

(a) Write a function that shifts the stored value of five character variables in a circular fashion, as follows:
Make c1, c2, c3, c4, c5 be variables of type char, and give them the initial values, 'A', 'B', 'C', 'D', 'E', respectively. Write a function "shift()" which will move all of the values to the left as follows: The new values of the global variables C1, C2, .... C5, will be 'B', 'C', 'D', 'E', 'A', respectively.

Test your function by running it five times, and print the current values of C1, C2, ..., C5, each time.

Your Outputs will be:

Current Values of String:

Assume that the Input String always has exactly five characters.

(b) Write a new function, List_Shift(), where the input and output strings are linked lists. In this case, the initial string will consist of a linked list with a header cell and five cells, each of which has two fields; one field for the character (A, B, etc ), and one field for the pointer to the next cell. Test your function in the same way as in (a) above.

You are encouraged to add additional fields to each cell, if you want to have additional pointers to simplify your code, i.e., You may use more than two fields in each cell if you wish. eg your program might be simpler if additional pointer are added.