UMBC CMSC201, Computer Science I, Fall 1994 Section 0101, 0102 and Honors

Quiz 1


True or False Questions, 1 point each

To practice taking this section. Select TRUE or FALSE in the pop-up menus after each question to record your answer. To submit your answers for grading, click on the "submit for grading" button.

On lynx, use down arrow to move to the next question or choice. Hit return to make your selection.

  1. When a C program is compiled, the source code written in C is transformed into object code that is written in machine language.

    Your answer:

  2. A variable may begin with a letter, a digit, or an underscore '_'.

    Your answer:

  3. An expression has a side effect if it changes the value stored in a variable.

    Your answer:

  4. The expressions ++x and x++ have the same value but have different side effects.

    Your answer:

  5. The difference between variables of type double and variables of type int is that double variables can store negative numbers but int variables cannot.

    Your answer:

  6. The comments in a C program begin with /* and end with */ and are ignored by the compiler.

    Your answer:

To submit this section for grading click here:


Multiple Choice, 2 points each

To practice taking this section. Choose the best answer in the pop-up menu after each question to record your answer. To submit your answers for grading, click on the "submit for grading" button.

On lynx, use down arrow to move to the next question or choice. Hit return to make your selection.

  1. Which of the following is an integer expression.
    a. the value given by a call to GetInteger().
    b. the value stored in an integer variable.
    c. the result of applying + to two integer expressions.
    d. All of the above.

    Your answer:

  2. We say that the minus operator, -, associates left to right meaning:
    a. In the expression (3 * 2) - (4 * 5), the expression on the left (3 * 2) is evaluated first.
    b. In the expression 5 - 3 - 2, the - on the left is evaluated first.
    c. In the expression 5 - 3 * 2, the - is evaluated first because it is on the left.
    d. All of the above.

    Your answer:

  3. The expression 19/8.0
    a. has type double and value 2.375.
    b. has type double and value 2.
    c. has type int and value 2.
    d. has type int and value 2.375.

    Your answer:

  4. What numbers are printed out when the following for loop is executed? (Note that the printf statement prints out the expression i+1 and not i.)
       for (i = 0 ; i < 12 ; i++ ) {
          printf("%d\n", i + 1) ;
       }
    

    a. The numbers 0 through 12 (including 0 and 12).
    b. The numbers 1 through 12 (including 1 and 12).
    c. The numbers 0 through 11 (including 0 and 11).
    d. The numbers 1 through 11 (including 1 and 11).

    Your answer:

To submit this section for grading click here:


Short Answers, 4 points each

This section cannot be graded on-line. To practice taking the exam, jot down your answer and click on the button after each question to see a sample solution.
  1. Evaluate the following expression. Recall that *, / and % have higher precedence than + and - and all five operators associate left to right.
       2 + 7 + 6 * 4 - 5 / 2  + 8 % 3  
    
    Click here for a sample answer.

  2. Write down (line by line) the output of the following program fragment.
          int a, b ;
          
          a = 6 ; 
          b = a + 7 ;
          printf("a = %d, b = %d\n", a, b) ;
          a += b / 3  ;
          printf("a = %d, b = %d\n", a, b) ;
          a = b = 2 * a ;
          printf("a = %d, b = %d\n", a, b) ;
          
    Click here for a sample answer.

  3. What is the output of the following code?
          int a ;
    
          a = 27 ;
          if ( a > 27 ) {
             printf("Georges Seurat\n") ;
          } else if ( a % 3 == 0) {
             printf("Edvard Munch\n") ;
          } else {
             printf("Joan Miro\n") ;
          }
          
    Click here for a sample answer.

Last Modified: Sep 3, 1995

Richard Chang, chang@gl.umbc.edu