## CS 1401, Quiz #10

**Date:** Monday, November 14, 2005

**Name** (please type legibly, ideally in block letters):
______________________________________________________________________

1. Use the ? construction to assign to the variable *sign* the value +1 is
*i* is positive and -1 if *i* is non-positive.

sign = (i > 0)? 1 : -1

2. What is printed by the following code fragment? Trace your results, do not just guess.
for (i = 0, j = 2; i < 4 && j > 0; i++, j--)
System.out.println(i + " " + j);
Tracing: i = 0 then 1 then 2
j = 2 then 1 then 0
What will be printed:
0 2
1 1