Exercises : Answer the following Question

Submitted by tushar pramanick on Mon, 02/25/2013 - 11:31

 

Workshop
To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson. The answers and hints to the questions and exercises are given in Appendix E, "Answers to Quiz Questions and Exercises."

 

Quiz

  1. Can a C compiler see the comments within your C program?
  2. What kinds of files does a C compiler actually produce?
  3. Does the exit() function return a value? How about the return statement?
  4. What is a header file?

 

    void main()
    {
       printf ("Howdy, neighbor! This is my first C program.\n");
       return 0;
    }

 

Exercises

1. Is #include <stdio.h> the same as #include "stdio.h"?

 

2. It's time for you to write your own first program. Referring to the program in Listing 2.1, write a C program that can print out a message: It's fun to write my own program in C.

 

3. Update the program in Listing 2.1 by adding one more newline character into the message printed out by the printf() function. You should see two lines of the message on the screen after running the updated executable file:

 

    Howdy, neighbor!
    This is my first C program.

 

4. What warning or error messages will you get when you're trying to compile the following program?

 

    #include <stdlib.h>
    #include <stdio.h>
    main()
    {
       printf ("Howdy, neighbor! This is my first C program.\n");
       exit(0);
    }

 

5. What error messages will you get when you're trying to compile the following program?

 

 

Related Items

The #define and #undef Directives

The #define and #undef Directives

The #define directive is the most common preprocessor directive, which tells the preprocessor to replace every occurrence of a particular character string (that is, a macro name) with a specified value (that is, a macro body).

The C Preprocessor Versus the Compiler

The C Preprocessor Versus the Compiler

One important thing you need to remember is that the C preprocessor is not part of the C compiler.

What Is the C Preprocessor?

If there is a constant appearing in several places in your program, it's a good idea to associate a symbolic name to the constant, and then use the symbolic name to replace the constant throughout the program. There are two advantages to doing so. First, your program will be more readable.

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q Why is random access to a disk file necessary?