MCS 275 homework #2 Due date: 19990215 D. J. Bernstein You are required to use dynamic linked lists for the following exercises. You may find the following definition

useful: struct intlist { int data; struct intlist *next; } ;

Exercise 3. Write a program that reads some integers and then prints them in the opposite order. For example, input 3 1 4 1 5 will produce results 5 1 4 1 3. Use the following method. Start with an empty list. For each integer that arrives, insert it at the beginning of your list: 3; 1 3; 4 1 3; 1 4 1 3; 5 1 4 1 3. After the final integer, print the list. Your program must be able to handle as much input as fits into memory. If memory is full, print an error message and stop immediately. Do not ask the user in advance how many integers there are. Exercise 4. Write a program that reads some integers and then prints them in ascending order. Use the following method. For each integer that you read, insert it at the appropriate spot in your linked

list: 3; 1 3; 1 3 4; 1 1 3 4; 1 1 3 4 5.

Your program must be able to handle as much input as fits into memory. If memory is full, print an error message and stop immediately. Do not ask the user in advance how many integers there are.