Assessment Tool

Lecture 4:  Arithmetic Expressions

Content Tested: Int and Double Types, Arithmetic in C

Lecture Content:

Goals:

Assessment Technique:  Expression Exercises

Purpose:

This activity allows instructors to see if students understand how to simplify arithmetic expressions in C.

Activity:

Simplify the following expressions (remember, these expressions are written in the C language and may not follow conventional mathematical rules):

1.  (15 / 2) * (3 / 2)
2.  15 * 3 / 2 / 2
3.  3 / 2 * 15 / 2
4.  15 / 2 * 3 / 2
5.  (15 * 3)/(2 * 2)
6.  (15.0 * 3) / 2
7.  (int) (15.0 / 2.0)
8.  8 + 7 % 5 - 6
9.  6 - -3 * 50 % (48 + 9 / 8)
10. (double) 10 / 4
11. (double) (10 / 4)
12. (int) ((double) 10) / (double) 4 + 1.0

Solutions:

1.  7
2.  11
3.  7
4.  10
5.  11
6.  22.5
7.  7
8.  4
9.  9
10. 2.5
11. 2.0
12. 3.0  (The integer 2 is added to 1.0, so the result is a double.)

Possible Uses of Activity: