COMP 356 Homework Assignment 5, Version 2
(25 points; submit to Moodle)
Acknowledgment. This assignment was written by Prof. Tim Wahls, with minor changes by John
MacCormick.
Modify the calculator example (les example.lex and example.cup from the example
COMP 356 Homework Assignment 4
Acknowledgment. This assignment was written by Prof. Tim Wahls, with minor changes by John
MacCormick.
Implement a class CarDealership in C+ that keeps track of the automobile inventory of a car dealership. The dealership se
COMP 356 Homework Assignment 2
Acknowledgment. Question 1 was written by Prof. Tim Wahls.
Instructions: Turn in a hard copy of question 1. Submit your solution to question 2 to Moodle.
Question 1 (10 pts)
Consider the following BNF denition of statements
COMP 356 Homework Assignment 1
Acknowledgment. This assignment was written by Prof. Tim Wahls.
1. Consider the following BNF denition of boolean expressions in an imaginary programming
language:
bool-expr true | false | id | not bool-expr | bool-expr and
COMP 356 Homework Assignment 7
Part A (6 points)
1. (3 points) Write a tail-recursive version of the WeirdFactorial function, which is dened as follows:
1 3 5 . . . n if n is odd
2 4 6 . . . n if n is even
WeirdFactorial(n) =
2. (3 points) Write a tail-re
COMP 356 Homework Assignment 8
Acknowledgment. The rst two questions are based on questions originally written by Prof.
Tim Wahls.
1. Consider the following C+ declarations:
typedef
typedef
typedef
typedef
char xtype;
char atype[10];
xtype axtype[10];
axt
COMP 356 Homework Assignment 3
Acknowledgment. This assignment was written by Prof. Tim Wahls, with minor changes by John
MacCormick.
Implement a queue class in C+ as a template class, with the type of element stored in the queue as the
parameter type. Yo
COMP356 Homework assignment 10: final project (15 points)
Write a program of your choice in either Scheme or Prolog. The purpose and nature of the program are
entirely up to you. The bulk of our last three classes will be devoted to lab periods for workin
COMP 356 Homework Assignment 9
Acknowledgment. This assignment was written by Prof. Tim Wahls, with minor changes by
John MacCormick.
1. Consider the following Prolog program:
parent(X, Y) :- mother(X, Y).
parent(X, Y) :- father(X, Y).
grandparent(X, Y) :
COMP 356 Homework Assignment 6
Acknowledgment. This assignment was written by Prof. Tim Wahls, with minor changes by John
MacCormick.
1. (3 pts) Write a Scheme function my-gcd that takes two integers and returns their greatest common
divisor (GCD). One el
COMP 356 Homework Assignment 3
Acknowledgment. This assignment was written by Prof. Tim Wahls, with minor changes by John MacCormick.
1. (5 pts) Suppose that for a particular C+ compiler, the size of an int in memory is 2 bytes, of a pointer
to char is 2