Name: ______________________________________________ Alpha: ________________
Describe help received: _________________________________________________________________
For this assignment
you will want to consult
the
C++ operator associativity/precedence table.

[10pts] For each of the below, circle the correctly
parenthesized version of the expression and circle
"precedence" or "associativity" as appropriate.
 x + y * z
evaluates as
(x + y) * z OR x + (y * z)
due to: precedence associativity
 x > y + z
evaluates as
(x > y) + z OR x > (y + z)
due to: precedence associativity
 cin >> x >> y
evaluates as
(cin >> x) >> y OR cin >> (x >> y)
due to: precedence associativity
 x = y = 1
evaluates as
(x = y) = 1 OR x = (y = 1)
due to: precedence associativity
 cin >> x = y
evaluates as
(cin >> x) = y OR cin >> (x = y)
due to: precedence associativity

[10pts]
Assuming the declarations in the left column, fill in the table. Each
expression should be taken as independent, i.e. if one expression modifies
some variable's value, those modifications do not carry over to the next
expression.
int n = 5;
double x = 1.5;
char c = 'R';
expression  type  value 
n = 2   
n == 2   
c < 200   
1 != x   
n*x   
 [80pts]
A year is a leap year if it is evenly divisible by 4,
Except that years that are evenly divisible by 100
are not leap years unless they are evenly divisible by
400. Clear? For example:
Year 
divisible by 4? 
divisible by 100? 
divisible by 400? 
Is leap year? 
703  no  no  no  not leap year 
704  yes  no  no  leap year 
700  yes  yes  no  not leap year 
800  yes  yes  yes  leap year 
Write a program that reads a year and prints out
(correctly!) Is Leap Year or Is Not Leap Year.
Here are two example runs.
$ ./hw
Enter year: 703
703 is not a Leap Year
$ ./hw
Enter year: 704
704 is a Leap Year
Turn in a printout of this cover sheet with your
answers to the questions, your source
code, and a screen capture of your program running each of the
four examples from the table above (703, 704, 700, and 800).