Basic Structure of C Program



Document Section:

                It consists a set of comment lines giving the name of the program, author name and some other details about the entire program.

Preprocessor Section (or) Link Section:

                It provides instructions to the compiler to link the functions from the C library.

Global Declaration Section:

                The Variables that are used in more than one function are called as Global Variables and these are declared in Global Declaration Section.

Main Function Section:

                Every C Program must have one function. i.e, main function. This section contains parts.
                1.Local declaration section.
                2.Statements section.
                The Local Declaration Section declares all the variables used in statements. The statements consists a sequence of executable statements. These 2 parts must appear between opening and closing curly braces. The program execution begins at the opening brace and ends at closing brace.

Sub Programming Section:

                It contains all the user defined functions. This section may be placed before or after main function.

Comments:

                Unexecutable lines in a program are called as comments. These lines are skipped by the compiler. These are Two types,

                1.Single  line comment.

                //------------------------     
                 

                2.Multi line Comment.

                /*-----------------------------
                    -----------------------------
                    ----------------------------- */ 

Preprocessor Statements:

                The preprocessor is a program that process the source code before it passes through the compiler.

#include:

                It is preprocessor file inclusion directive and is used to include header files. It provides instructions to the compiler to link the functions from the C library.

Syntax:

#include "file_name"
            (or)
#include <file_name>

                When the file name is included within the double quotation marks, the search for the file is made first in the current directory and then the standard directories(TC(or)Turbo3). Otherwise when the file name is included within  angular braces, the file is search only in standard directories.
                    
                stdio.h :- standard input and output
                                        header file.
                conio.h :- console input and output
                                        header file.
                console units: keyboard and monitor.
                These 2 header files are commonly included in all C Programs.


printf :

                It is a function and is used to print data on the standard output device(monitor).

Syntax:

                                              format string

                                                        ↡

                       int     printf("control string" [arg1, arg2, ............ argn]);

                Eg:           printf("Welcome to C Programming");



Next Topic        :  Installation of Turbo C++

No comments:

Post a Comment