Section 0101, 0102, 0103 & Honors, Fall 1995

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. The string "Delaware" uses 8 bytes of memory.

    Your answer:

  2. The function call IthChar("New York", 7) will return the character 'k'.

    Your answer:

  3. The constants "0" and '0' may be used interchangeably.

    Your answer:

  4. The keyword typedef is used to define new variables.

    Your answer:

  5. During the linking phase of compiling a program, the linker looks in the header files to see which libraries are used by the program.

    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 items belong in a header file?


    a. type definitions
    b. #define statements
    c. function prototypes
    d. All of the above

    Your answer:

  2. A C library contains


    a. Built-in commands of the C language
    b. the source code for many useful functions
    c. the object code for many useful functions
    d. All of the above

    Your answer:

  3. The on-line manual on the UNIX system provides the following information about a function you may want to use, except


    a. The function prototype of the function.
    b. The location of the source code of the function
    c. The name of the header file to include if you want to use the function
    d. An English description of what the function does

    Your answer:

  4. The function call SubString("New Hampshire", 5, 7) returns


    a. the string "Hampshi"
    b. the string "Ham"
    c. the string "ampshir"
    d. the string "amp"

    Your answer:

  5. Suppose that the header file foo.h contains the function prototype of the function UseMe. You should include foo.h in a file mine.c


    a. if the function UseMe appears somewhere in mine.c
    b. if a function in mine.c calls a function that calls UseMe
    c. if the function UseMe appears in the function main
    d. if the function UseMe will be called when the program is executed

    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.

In the following questions, no syntax errors have put in deliberately. (So, "there is a syntax error" is not the right answer and will receive no credit.) Please mark your final answer clearly. In order to receive partial credit, you must show your work.

  1. Write a function called AllDigits which takes a string parameter and returns a Boolean value. If every character in the string parameter is a digit ('0' through '9') then the function should return TRUE. Otherwise, the function returns FALSE.

    Sample solution

  2. The following program contains several global variables. Trace through the program and write down the output of the program. It is important that you write down the output in the order that they would appear when the program is executed.
    	#include <stdio.h>
    	
    	void xyzzy(int) ;
    	
    	int a = 3, b = 6, c = 9, d = 12 ;
    	
    	void xyzzy(int a) {
    	   int b ;
    	
    	   b = a - 1 ;
    	   c = 2 * b + 12 ;
    	   d = b + c + 3 ;
    	   a = c - b ;
    	   printf("xyzzy: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
    	}
    	
    	main() {
    	   int b = 5, d = 10 ;
    	
    	   printf("main: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
    	   xyzzy(a) ;
    	   printf("main: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
    	}
    

    Sample solution


Last Modified: Nov 22, 1995

Richard Chang, chang@gl.umbc.edu