Chapter 3 Exercise Set 1: CPE PracticeΒΆ

  1. What is output by the following snippet?

    int a = 1, b = 2;
    float f = a / b;
    cout << f << endl;
    
  2. What is output by the following snippet?

    double f = 4.997
    int n = int(f);
    int m = (int)f;
    cout << n << ' ' << m << endl;
    
  3. What is the output of the following program?

    #include <iostream>
    using namespace std;
    
    void f() {
        cout << "C";
    }
    
    void g() {
        cout << "B";
    }
    
    void h() {
        cout << "A";
    }
    
    int main() {
    
        f();
        g();
        h();
        cout << endl;
        return 0;
    }