CS 316 - Programming Assignment 6

This assignment has five problems from pages 298-305 at the end of Chapter 6 of our textbook, Programming Language Pragmatics.

1.) Do Exercise 6.4, using Scheme instead of Lisp.

2.) Do Exercise 6.10. Write your answers in terms of C's ternary conditional expression. That is, show how to use the ternary conditional expression to implement the short-circuited boolean operators && and ||.

3.) Do Exercise 6.14, but implement both in-order and post-order iterators. So write two programs that modify Tree.java (which is included in the zip file) and call them TreeInOrder.java and TreePostOrder.java.

4.) This is a modification of Exercise 6.22. Rewrite the piece of code in C without using a goto, a continue or a break statement. In your opinion, which is a better piece of code, your structured example, or the example in the exercise with the goto statement. Give a justification for your opinion. What if you are allowed to use a continue or a break statement? Does that improve your code?

5.) This is a modification of Exercise 6.37. Investigate the order of evaluation of function parameters using the C language and the lcc, gcc and Visual Studio compilers. Are parameters evaluated left-to-right or right-to-left? One of these three compliers is different than the other two; which one is it? Write a small, simple program in which the order of parameter evaluation makes a difference in the results of the computation. Use it and its assembly language listings from each of these compilers to demonstrate your results.

Turn in a zip file called CS316Hw6Surname.zip containing your answers to the above problems and also the original files contained in h6.zip. This assignment is due Tuesday, April 15.


Return to the main homework page.
Return to the CS 316 home page.


compliments and criticisms