1
h02
CS16 S17
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu
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: Homework 2: Introduction to C++

ready? assigned due points
true Thu 04/06 12:30PM Tue 04/11 12:30PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN IN THE LECTURE LISTED ABOVE AS THE DUE DATE. There is NO MAKEUP for missed assignments.
In place of that, we drop the two lowest scores (if you have zeros, those are the two lowest scores.)


Read Chapter 2, sections 2.1 thru 2.3 (If you do not have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).

    1. (5 pts) What are the five main components of a computer?
    2. (5 pts) What is the role of a compiler?
    3. (5 pts) What is object code?
    4. (5 pts) If the following statement were in a C++ program, what would it do?
    cout >> "An apple a day";
    
    5. (5 pts) If the following statement were in a C++ program, what would it do?
    cout << "Keeps the doctor away";
    
    6. (15 pts) Complete this C++ program designed to calculate the area of a trapezoid. The program gets the 2 base and height parameters from the program user and should then print out a statement that says: The area of this trapezoid is: some number here
    #include <iostream>
    using namespace std;
    int main () 
    {
    	int area, base1, base2, height;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    } //end program