So, in our previous lesson, we have seen how C programs are
written. Before we proceed any further, we must know that a C program file
is a text file you create with your text editor. And all C files have these
following sections:
Headers and definitions
-----------------------
Variable declarations
Function1
Function2
.
.
.
.
------------------------
Some of these sections can be reordered, but the above is a representation of
the usual arrangement. The short C program that displayed
"This is your very first C program." is the simplest possible C program.
This is because it has nothing more than a header and one function.
Header #include "stdio.h" Function main()
{
/* main */
printf("This is your very first C program. ");
} /* main */
Most C programs refer to special names that the programmer need not define.
These names are defined in header files and are included as part of the program when it is compiled.
Headers generally contain system-related information. A header file is brought
into the program with the following instruction

#include "name"
In our example, the expression we have used for the above program is #include "stdio.h"
In other words, "stdio.h" is the name of the "header file." Some C compilers use this format : #include

Most programs use stdio.h as a required header. Some programs need additional header files.
We will encounter these header files as we proceed.

Functions, Comments and Statements


C program are made of functions. A function is a unit of program that performs a single action.
A function begins running when its name is used in the program. This is known as calling a function.
Every function has a name in C. Any name may be used in a program if it:

Begins with a letter (In C, the underscore character ( _ ) is considered a letter),

Uses only letters and digits in the name ( punctuation not allowed ) and

Should consist of not more than 8 characters . However, some C compiler allow upto 31 characters in a function name

All C programs need a main function. Function name main ( )
Start { /* main */
Body printf ( “This is your very first C program.”);
End } /* main */The name of the function is main. The function name is followed by a set of parentheses.

Everything within a C function is enclosed in left and right curly brackets – { and }. A Comment is a text for human reading only. It is completely ignored by the C compiler. Each comment is preceded by a slash-star /* and is ended with a star-slash */.
Here is an example
/* This is your very first C program */

A comment can be inserted almost anywhere that a space can appear in a C program.

A function’s body consist of a series of C statements that describe what the function is to do.

A statement is basically some action to be performed. All C statements end with a semi-colon.

In the example, the function main consists of a single statement that starts with printf. printf is a function that prints everything between the starting and ending quote marks on the computer screen/monitor. The function printf is called by using its name and then the text to be displayed should be enclosed by double quotes and set of parentheses e.g printf ( “This is your very first C program.”)



16th December,2000