1
h01
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"

h01: Chapter 1, especially pp. 18-32

ready? assigned due points
true Thu 09/22 02:00PM Tue 09/27 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.)


Reading: Read Chapter 1, with a special focus on pages 18-32. 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. (4 pts) Before you come to your first discussion section (lab), PLEASE visit this website and create your College of Engineering account (unless you already have one). Then write your College of Engineering username below. (DO NOT WRITE YOUR PASSWORD!!!!! NEVER WRITE DOWN YOUR PASSWORD!!! Just your username!) Website: https://accounts.engr.ucsb.edu/create Write your username here:
  2. (5 pts) Not including any comments that may appear, what are the first two lines that typically begin a C++ program that is going to may either output on the screen, and/or read input from the keyboard?
  3. 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:

    1. (5 pts) Syntax errors that result in an error message:
    2. (5 pts) Syntax errors that result in an warning message:
    3. (5 pts) Logic errors:
  4. (4 pts) As you discovered when you read the textbook, for the most basic kind of input and output, C++ uses two words, and two symbols, along with variables and quoted strings. Unlike in some other languages (e.g. Python), quoted strings must always use double quote marks "like this", never single quotes 'like this'. (Single quotes are used for another purpose in C++.)

    Inside a quoted string, \n means “newline”. Quoted strings can only be output, while the value of a variable can be either output to the screen, or read in from the keyboard. Variable names are not put inside quotation marks. Also remember that every line of C++ that does input or output must end in a semicolon.

    Write a line of C++ that will print out Hello World followed by a newline?. (For full credit, be sure to end your line with a semicolon. That’s true of all the problems in this section, but this is the only time I’ll remind you.)

  5. (4 pts) Assuming the variable int age; has already been declared, what line of code will read in a value for age from the user?
  6. (4 pts) Assuming the variable int balance; has already been declared, write two lines of code that will ask (prompt) the user for a value for balance, and then read in the value of balance.
  7. (4 pts) The textbook describes C++11 on p.27. Briefly, what is C++11? (A one sentence answer is good enough. Note that if your textbook doesn’t describe C++11 on p. 27, then you may have the wrong edition. You need the ninth edition.)