1 |
h04 |
CS16 F16 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | section 9am or 10:30am |
||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" |
h04: Homework 4
ready? | assigned | due | points |
---|---|---|---|
true | Tue 10/04 02:00PM | Thu 10/06 02:00PM |
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the three lowest scores (if you have zeros, those are the three lowest scores.)
Please:
- No Staples.
- No Paperclips.
- No folded down corners.
Read Chapter 2 and Ch 3.1 (If you do not have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).
PLEASE MARK YOUR HOMEWORK CLEARLY, REGARDLESS OF IF YOU WRITE IT OUT IN INK OR PENCIL!
-
1. (1 pts) Which Boolean operator, when used with 2 logic expressions, yields TRUE only if both expressions are TRUE?
2. (1 pts) What is wrong with this C++ expression?
if (size = 4)
cout << "The size is too small";
x = 10;
while ( x > 0) {
cout << x << endl;
x = x – 3;
}
COUNTDOWN TO ZERO: 10
COUNTDOWN TO ZERO: 9
...
COUNTDOWN TO ZERO: 1
COUNTDOWN TO ZERO: LIFT OFF!
a) (x == 6)
b) !(y > 0)
c) ((x == 6) || (y < 20))
d) ((x >= 3) && (z <= 12))
e) ((x > y) && (y < z))
f) ((!(x < z) || (y > z)) && (z == 12) && (y == 10))
.