Name: ________________________________

Honor Code Acknowledgment: _____________________________


CPS 6, Summer 1999                 Random Quiz 3

Due: Thursday, May 27, 1999                 6 points


Problem 1: In and Out (2 points)

Consider the following lines of code.

        string name;
        int a, b;

        cin >> name;
        cin >> a >> b;
        cin >> b;

        cout << "name " << name << endl;
        cout << "a is " << a << endl;
        cout << "b is " << b << endl;
    

If the user types the following input:

Knuth 5 8 2 4

What is the output?



Problem 2: Output (3 points)

What is the output of the following cout statements?

        cout << 5 + 3 * 4 << endl;
        cout << 5 * 3 + 4 << endl;
        cout << 23 % 6 % 8 << endl;
        cout << 45 / 10 << endl;
        cout << 45.0 / 10 << endl;
        cout << 10 - 2 * 8 - 4 << endl;








Problem 3: Balloons (1 point)

What is wrong with the following statements in a student program (see the complete Balloon class in section 3.4)?

    Balloon devil;

    devil.Burn();
    devil.Ascend(10);
    devil.Vent();
    devil.Descend(10);