Homework #2
Due Friday, April 24, 11:59 PM
Answer to each question should be in a separate file. The files
should not be written to after the due date.
Suppose integers a = 2, b = -3, c = 5, d = -7, e = 11
- [3 points] Write a program to print out the values of the following
expressions. What are the values of each of the variables after
everything has been executed? Assume that all the statements are
executed in order (i.e. the statements do not exist in isolation
from one another.) Click here for
a note on precedence
- a / b / c
- 7 + c * -- d / e
- 2 * a % - b + c + 1
- 39 / - ++ e - + 29 % c
- a += b += c += 1 + 2
- a *= b = c + 5
- [1 point] What do you get if you try to print the value of the
following expression: 7 - + ++ a % (3 + b)
- [1 point] What do you get if you try to print the value of the
following expression using the %d format: 'A' + 5. What do you get if
you use the %c format? What can you say this expression means?
Back to Grading & Homeworks page