Section 0101, 0102, 0103 & Honors, Fall 1995

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. An integer variable that has never been assigned any value must have the value 0.

    Your answer:

  2. The main reason to use good indentation in a C program is to make it readable.

    Your answer:

  3. The purpose of a compiler is to turn source code into machine language.

    Your answer:

  4. The fraction 1/5 can be stored exactly (without round-off error) in a double variable.

    Your answer:

  5. The value of the expression 23%3 is 3.

    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. Consider the integer expression (17+3)*(14+9)+3. The fact that multiplication has higher precedence than addition tells you that:


    a. The expression (17+3) is evaluated before (14+9)+3.
    b. The expression (17+3) is evaluated after (14+9)+3.
    c. The expression above is equivalent to (17+3)*((14+9)+3).
    d. The expression above is equivalent to ((17+3)*(14+9))+3.

    Your answer:

  2. Consider the integer expression (4+5)-(7+9)-(2+4). The fact that subtraction associates left to right tells you that


    a. The expression (4+5) must be evaluated before the expression (7+9).
    b. The expression (7+9) must be evaluated before the expression (2+4).
    c. The expression above is equivalent to ((4+5)-(7+9))-(2+4).
    d. The expression above is equivalent to (4+5)-((7+9)-(2+4))

    Your answer:

  3. Which of the following is not an integer expression?


    a. 14%3
    b. 14/3.0
    c. (int)(14.0/3.0)
    d. 14/3

    Your answer:

  4. Which of the following expressions does not have a side effect?


    a. i == 17 - i
    b. n = GetInteger()
    c. n = m = 0
    d. i++= 17 - i

    Your answer:

  5. Which of the following statements correctly describes the expression:
    	    (n = 3) * 2 + (n = n + 10) * 4
    	   

    a. The expression has a syntax error.
    b. The = symbols should be replaced by ==.
    c. A program containing this expression will crash if the expression is executed.
    d. The value of the expression depends on which compiler is used.

    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 follow the link after each question to see a sample solution.

  1. Write down the output of the following program fragment.
    	int n ;
    
    	n = 3 ;
    	if (n != 3) {
    	   printf("Captain Fantastic\n") ;
    	} else if (n * 2 <= 5 + n) {
    	   printf("Brown Dirt Cowboy\n") ;
    	} else {
    	   printf("Rocket Man\n") ;
    	}
    
    Sample Solution

  2. What is the output of the following code fragment?
    	int i;
    
    	for (i = 0 ; i < 9 ; i = i + 2) {
    	   printf("%d\n", 2 * i) ;
    	}
    
    
    Sample Solution

  3. What is the output of the following code fragment?
    	int n, m ;
    
    	n = 1 ;
    	m = 1 ;
    	while (n < 30) {
    	   printf ("n = %d, m = %d\n", n, m) ;
    	   m = m + 2 ;
    	   n = n + m ;
    	}
    
    Sample Solution

Last Modified: Tue Oct 3 09:56:17 EDT 1995

Richard Chang, chang@gl.umbc.edu