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

Quiz 2


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 function is called, the number of actual parameters should equal the number of formal parameters declared in the function's prototype.

    Your answer:

  2. In order to compile a program, the source code for every function used by the program must be placed in a single file.

    Your answer:

  3. The UNIX archive command ar can be used to produce a library file from a list of object files (.o files).

    Your answer:

  4. In C, the typedef facility is used to create global variables.

    Your answer:

  5. The character constant 'a' is the same as the string constant "a".

    Your answer:

  6. In the header file of the graphics library, the purpose of the following directives is to make sure that the body of the header file is never read twice by the compiler.
          #ifndef _graphics_h
          #define _graphics_h
            .
            .
            .
          #endif
          

    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. The advantage of breaking up a very large program into several files is:
    a. smaller files are easier to edit.
    b. programmers can work on different parts of the program separately.
    c. when one of the files is changed, only that file has to be recompiled.
    d. All of the above.

    Your answer:

  2. During the linking phase of compilation:
    a. The header files and the source code files are combined.
    b. Source code written in C is translated in to object code.
    c. Object code produced by the programmer and object code from libraries are combined to make the a.out file.
    d. All of the above.

    Your answer:

  3. During the preprocessing phase of compilation:
    a. The header files and the source code files are combined.
    b. Comments are removed.
    c. The #define directives are processed.
    d. All of the above.

    Your answer:

  4. The purpose of a header file is to
    a. hide the main program from the client.
    b. make the prototypes of the functions in a library available to the client.
    c. implement the functions in a library.
    d. All of the above.

    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. The following program contains global variables. Write down the output of the program.
        #include <stdio.h>
        
        void foo(int) ;
        int a = 10, b = 20, c = 30 ;
        
        void foo (int a) {
           int b = 3 ;
          
           c = a + b ;
           b = b + 1 ;
           printf("foo: a = %d, b = %d, c = %d\n", a, b, c) ;
        }
        
        main() {
           int a = 2 ;
          
           printf("main: a = %d, b = %d, c = %d\n", a, b, c) ;
           foo(5) ;
           printf("main: a = %d, b = %d, c = %d\n", a, b, c) ;
        }
        

    Click here for a sample answer.

  2. Write a function hundred that takes an integer parameter and returns the digit (as an integer) in the hundred place of the parameter. For example, hundred(12345) should return the integer value 3, and hundred(12) should return 0. You may assume that the parameter is non-negative.

    Click here for a sample answer.


Last Modified: Tue Dec 6 15:33:49 EST 1994

Richard Chang, chang@gl.umbc.edu