Sams Teach Yourself C in 21 Days

(singke) #1
Answers 831

F


Answers for Day 2

Quiz


  1. A block.

  2. The main()function.

  3. You use program comments to make notations about the program’s structure and
    operation. Any text between /and/is a program comment and is ignored by the
    compiler. Additionally, you can use single line comments. Any text on the same
    line following two forward slashes (//) is considered a comment.

  4. A function is an independent section of program code that performs a certain task
    and has been assigned a name. By using a function’s name, a program can execute
    the code in the function.

  5. A user-defined function is created by the programmer. A library function is sup-
    plied with the C compiler.

  6. An #includedirective instructs the compiler to add the code from another file into
    your source code during the compilation process.

  7. Comments shouldn’t be nested. Although some compilers let you to do this, others
    don’t. To keep your code portable, you shouldn’t nest comments.

  8. Yes. Comments can be as long as needed. A comment can start with /and won’t
    end until a
    /is encountered.

  9. An include file is also known as a header file.

  10. An include file is a separate disk file that contains information needed by the com-
    piler to use various functions.


Exercises


  1. Remember, only the main()function is required in C programs. The following is
    the smallest possible program, but it doesn’t do anything:
    void main(void)
    {
    }
    This also could be written
    void main(void){}

  2. a. Statements are on lines 8, 9, 10, 12, 20, and 21.
    b. The only variable definition is on line 18.
    c. The only function prototype (for display_line()) is on line 4.


49 448201x-APP F 8/13/02 11:22 AM Page 831

Free download pdf