UMBC CMSC201, Computer Science I, Spring 1994 Sections 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. All variables must be declared before they are used.

    Your answer:

  2. The expression ++x has a side effect.

    Your answer:

  3. The expressions a + b % c and (a + b) % c are equivalent

    Your answer:

  4. The expressions a - b - c and a - (b - c) are equivalent.

    Your answer:

  5. The expressions 15 / 3 and 15 / 3.0 are equivalent.

    Your answer:

  6. The following declaration is used to declare a variable with Boolean type.
    	bool flag ;
          

    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 a legal variable name in C:
    a. FiftyFifty
    b. 50_50
    c. Fifty-Fifty
    d. Fifty/fifty

    Your answer:

  2. In C, the term ``white space'' means:
    a. A single space, tab or new-line character.
    b. Several spaces, tabs or new-line characters.
    c. Any combination of spaces, tabs and new-line characters.
    d. All of the above.

    Your answer:

  3. What is the value of the integer expression: 1 - 3 * 5 + 6 / 4 % 2
    a. 0
    b. -6
    c. -8
    d. -13

    Your answer:

  4. By the rules of short-circuit evaluation, in the following expression,
         p || ( n < 3 )  
      

    a. if p is true, then n < 3 will not be evaluated.
    b. if p is false, then n < 3 will not be evaluated.
    c. if p is true, then n < 3 will be evaluated.
    d. None of the above.

    Your answer:

  5. If p and q are Boolean variables, which expression is equivalent to the following expression?
         !( p || q)
      

    a. !p || !q
    b. p || q
    c. !p && !q
    d. p && q

    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.

There are no syntax errors in this section.

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

  2. What is the output of the following code?
          int a, b ;
    
          a =  6 ;
          b =  9 ;
          if ( a * b == 42 ) {
             printf("Hitchhiker's Guide\n") ;  
          } else if ( a - b < -3  ) {
             printf("Milliway's\n") ;
          } else {
             printf("Life, the Universe and Everything\n") ;
          }
          
    Click here for a sample answer.

  3. What is the output of the following code?
          int n, i ;
         
          i = 0 ;
          n = 2048 ;
          while (n > 0) {
             n = n / 2 ;
             printf("n = %d\n", n) ;
             i++ ;
          }
          printf ("i = %d,  n = %d\n", i, n) ;
          
    Click here for a sample answer.

Last Modified: Mon Sep 4 15:33:59 EDT 1995

Richard Chang, chang@gl.umbc.edu