CISC181 Midterm Exam 1
E01, 07S, Phill Conrad, University of Delaware
03/09/2007

Name: ________________________________________________________________


UD Email: _____________________________________________@ udel.edu

 

Are you classified as a freshman (circle one):        YES          NO


Circle your lab section number:      

     020 (Mon 9:05)        021 (Mon 10:10)        022  (Mon 11:15)

     030 (Wed 9:05)        031 (Wed 10:10)        032  (Wed 11:15)

Total Points: ???


A hint about allocating your time:

You need to answer 100 points worth of questions in 50 minutes, so....


  1. (2 pts) Which of the following is a backslash?

    1. \
    2. /
  2. (2 pts) 232 is approximately which of the following

    1. 1 billion
    2. 2 billion
    3. 4 billion
    4. 8 billion
    5. 16 billion
  3. (2 pts) 231 is approximately which of the following

    1. 1 billion
    2. 2 billion
    3. 4 billion
    4. 8 billion
    5. 16 billion
  4. (4 pts) For this question, please refer to program p01.cc on the code handouts distributed with this exam.

    The program p01.cc is designed to test whether the function discriminant(), defined separately in disc.cc, is working correctly.

    On line 25, there is some code missing. Which of the following will correctly complete this program?

    1. if ( expectedValue = actualValue)
    2. if ( expectedValue == actualValue)
    3. if ( fabs(expectedValue-actualValue) < tolerance )
    4. if ( fabs(expectedValue-actualValue) > tolerance )
    5. if ( fabs(actualValue-expectedValue) > tolerance )
  5. (4 pts) For this question, please refer to program p01.cc

    Lines 9-12 contains which of the following?.

    1. function prototype
    2. function call
    3. function definition
  6. (4 pts) For this question, please refer to program p01.cc

    Line 21 contains which of the following?.

    1. function prototype
    2. function call
    3. function definition
  7. (4 pts) For this question, please refer to the file p01.cc

    On line 9, a, b and c are:

    1. binary operators
    2. operands
    3. actual parameters
    4. formal parameters
    5. pointers
  8. (4 pts) For this question, please refer to the file p01.cc

    On line 21, 4.0, 6.0 and 9.0 are:

    1. binary operators
    2. operands
    3. actual parameters
    4. formal parameters
    5. pointers
  9. (4 pts) For this question, please refer to p02.cc

    What is the output of this program?

    1. 3
    2. 7
    3. 21
    4. no output; just another unix prompt
  10. (4 pts) For this question, please refer to p03.cc

    What is the output of this program?

    1. 3
    2. 7
    3. 21
    4. no output; just another unix prompt
  11. (4 pts) For this question, please refer to p04.cc

    Which of the following will be the output of this program?

    1. b
      d
      aa
      c
      
    2. d
      aa
      c
      b
      
    3. aa
      b
      c
      d
      
    4. b
      d
      c
      
      aa
    5. b
      d
      c
      aaa
  12. (4 pts) Consider the following message:

    strauss.udel.edu% CC testQuadEqn.cc 
    Undefined                       first referenced
     symbol                             in file
    int howManyRoots(double,double,double)           testQuadEqn.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    strauss.udel.edu% 
      

    Which of the following is the best explanation for this message?

    1. The file testQuadEqn.o does not exist.
    2. The file testQuadEqn.cc does not exist.
    3. The file testQuadEqn.cc contains a syntax error, and therefore did not compile.
    4. The file testQuadEqn.o contains a syntax error, and therefore did not compile.
    5. The file testQuadEqn.cc contains a function call that has no matching function definition.
  13. (4 pts) The octal number 36, when converted to binary is:

    1. 011110
    2. 011101
    3. 110011
    4. 00110110
    5. 00100010
  14. (4 pts) The base 16 number 36, when converted to binary is:

    1. 011110
    2. 011101
    3. 110011
    4. 00110110
    5. 00100010
  15. ( 4 pts) The binary number 0110 0011 when converted to decimal is:

    1. 4
    2. 9
    3. 63
    4. 99
    5. 143
  16. (4 pts) The binary number 0110 0011 when converted to base 8 is:

    1. 4
    2. 9
    3. 63
    4. 99
    5. 143
  17. (4 pts) Which of the following lines of code contains the stream extraction operator?
    1. cin >> x;
    2. cout << x;
    3. using std::cin;
    4. stream.insert();
    5. stream::insert();
  18. (4 pts) Which of the following for loops will correctly print the following sequence:

      5
      4
      3
      2
      1
      0
    
    1. for (i=5; i<=0; i--)
        cout << i << endl;
      
    2. for (i=5; i>=0; i--)
        cout << i << endl;
      
    3. for (i=5; i<=0; i++)
        cout << i << endl;
      
    4. for (i=5; i>=0; i++)
        cout << i << endl;
      
  19. (4 pts) Which of the following for loops will produce a so-called "infinite loop", terminating only when the user hits CTRL/C or CTRL/Z, or when the integer value "wraps around" from a large positive number to a large negative number?

    1. for (i=10; i<=0; i--)
        cout << i << endl;
      
    2. for (i=10; i>=0; i--)
        cout << i << endl;
      
    3. for (i=10; i<=0; i++)
        cout << i << endl;
      
    4. for (i=10; i>=0; i++)
        cout << i << endl;
      
  20. (4 pts) Which of the following is a correct explanation of this command?

      CC -c lab03.cc
      
    1. This command links the program lab03.cc, producing lab03.o
    2. This command compiles the program lab03.cc, but does NOT link it, producing the file lab03.o
    3. This command compiles and links the program lab03.cc, producing the executable a.out
    4. This command checks the syntax of lab03.cc, but does not produce any output file
    5. This command executes the instructions in the C++ file lab03.cc
  21. (30 pts) Write a complete C++ program to solve the following problem, including

    Problem Statement: Ask the user of the program to input three integers that are all different. You should then print out only one word: either odd, even or error, computed as follows:

    Your program should provide appropriate prompts to the user for entering the three numbers.

    Here is some sample input and output:

    input output
    9 3 2 odd
    7 8 1 odd
    -2 0 -5 error
    3 9 4 even
    5 5 1 error
    2 2 2 error
    1 3 1 error
    4 3 7 even
    0 1 2 odd
    0 2 5 even
  22. Extra space for you to write your program

    Extra space for you to write your program

    End of Exam E01