UMBC CMSC201, Computer Science I, Spring 1994 Sections 0101, 0102 and Honors

Midterm Exam, Multiple Choice Section


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. A function f which takes two integer parameters and does not return any value should have the function prototype:
    a. f(int, int) ;
    b. void f(int) ;
    c. void f(int, int) ;
    d. int f(void, void) ;

    Your Answer:

  2. A break statement inside a case of a switch statement
    a. causes the next case to be executed next.
    b. causes the default case to be executed next.
    c. causes the statement after the switch statement to be executed next.
    d. causes the statement after the innermost loop to be executed next.

    Your Answer:

  3. What is the output of the following code fragment?
        int a = 3, b = 2 ;
        
        if ( a < b ) {
           printf("Dwarf Marigold\n") ;
        } else if ( a < b + 2 ) {
           printf("Purple Iris\n") ;
        } else {
           printf("Yellow Crocus\n") ;
        }
      

    a. Dwarf Marigold
    b. Purple Iris
    c. Yellow Crocus
    d. No output is produced.

    Your Answer:

  4. The expression 19/2
    a. has type double and value 9.5.
    b. has type int and value 9.
    c. has type double and value 10.
    d. has type int and value 10.

    Your Answer:

  5. What is the value of the following expression?
         1 * 2 + 3 * 4 - 5 + 6
      

    a. 12
    b. 13
    c. 14
    d. 15

    Your Answer:

  6. Let flag be a Boolean variable. Note that there is an assignment in the condition of the if statement. The output of the following program fragment is:
        flag = FALSE ;
        if (flag = FALSE) {
           printf("Zinnia") ;
        } else {
           printf("Petunia") ;
        }
      

    a. Zinnia
    b. Petunia
    c. FALSE
    d. No output is produced.

    Your Answer:

  7. What is the effect of the following code?
        int i, total ;
      
        total = 0 ;
        for (i = 3 ; i <= 17 ; i += 3) {
           total += i ;
        }
        printf("%d\n", total) ;
      

    a. It prints out the integers from 3 to 17.
    b. It prints out the multiples of 3 from 3 to 17.
    c. It prints out the sum of the integers from 3 to 17.
    d. It prints out the sum of the multiples of 3 from 3 to 17.

    Your Answer:

  8. The following Boolean expression is equivalent to which of the given expressions?
        !( (n > 17) && (n < 24) )
      

    a. (n < 17) || (n > 24)
    b. (n <= 17) || (n >= 24)
    c. (n < 17) && (n > 24)
    d. (n <= 17) && (n >= 24)

    Your Answer:

  9. Considering short circuit evaluation, after executing the following statments,
        int a ;
        bool flag ;
      
        a = 3 ;
        flag = (7 > 1) || (a = 11) ; 
      

    a. flag is TRUE and a is 11.
    b. flag is TRUE and a is 3.
    c. flag is FALSE and a is 11.
    d. flag is FALSE and a is 3.

    Your Answer:

  10. What is the output of the following code fragment?
        int a, b ;
        
        a = b = 4 ;
        a += b++ % 3 ;
        printf("a = %d, b = %d\n", a, b) ;
      

    a. a = 5, b = 4
    b. a = 5, b = 5
    c. a = 6, b = 4
    d. a = 6, b = 5

    Your Answer:

To submit this section for grading click here:

Last Modified: Mon Sep 4 15:52:08 EDT 1995

Richard Chang, chang@gl.umbc.edu