1
h02
CS16 W18
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu section
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

h02: Chapter 2: Variables and assignments, input and output

ready? assigned due points
true Tue 01/23 09:00AM Tue 01/30 08: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.

Complete your reading of Chapter 1, section 1.3 pages 27-32, Chapter 2 sections 2.1 thru 2.2, pages 39-59 (If you don’t have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).

    1. (6 pts) The author describes the difference between "syntax errors" and "logic errors", and also the difference between syntax errors that produce an "error message" vs. those that produce a "warning message". Briefly explain each of the items below in a way that makes the DIFFERENCES among them clear:
    i. Syntax errors that result in an error message:
    ii. Syntax errors that result in an warning message:
    iii. Logic errors:
    2. (1 pt) If the following statement were in a C++ program, what would it do?
    cout >> "I love oranges and apples";
    3. (1 pt) If the following statement were in a C++ program, what would it do?
    cout << "The world goes round and round"
    4. (4 pts) Show 2 different ways to initialize variables in C++?
    5. (2 pts) Is this variable declaration statement in C++ a good one? Why or why not?

    double int=30;

    6. (2 pts) How do you write the following in ONE LINE in C++: Add a to b and subtract that sum from c, then divide that result by d, and store the final result in e? Assume all variables are of type double.