cin Worksheet

Assume the following declarations:

     int a, b, c;
     float x, y, z;

For each of the following, tell what value, if any, will be assigned to each of these variables, or explain why an error occurs. Use the given input data:

  1. cin >> a >> b >> c
        >> x >> y >> z;
    Input:
    1   2   3
    4 5.5 6.6
  2. cin >> a >> b >> c;
    cin >> x >> y >> z;
    Input:
    1
    2
    3
    4
    
    5.5
    6.6
  3. cin >> a >> x;
    cin >> b >> y;
    cin >> c >> z;
    Input:
    1 2.2
    3 4.4
    5 6.6
  4. cin >> a >> b >> c;
    cin >> x >> y >> z;
    Input:
    1 2.2
    3 4.4
    5 6.6
  5. cin >> a;
    cin >> b >> c;
    cin >> x >> y;
    cin >> z;
    Input:
    1   2   3
    4 5.5 6.6
  6. cin >> a
        >> b >> c
        >> x >> y
        >> z;
    Input:
    1   2   3
    4 5.5 6.6
  7. cin >> a >> b;
    cin >> c >> x >> y >> z;
    Input:
    1   2   3   4 5.5
    6.6 7 8.8 9.9  10

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002