Another way to learn New Technology

What are the function of C Program? Explain the main( ) function in detail?

1 1,109

The function of C Program:

A C program can be viewed as a group of building blocks called functions. A function is a subroutine that may include one or more statements designed to perform a specific task. To write a C program, we first create functions and then put them together. A C program may contain one or more section shown. That are:

1.    Documentation

2.    Link Section

3.    Definition Section

4.    Global Declaration Section

5.    Main( ) Function Section


Declaration part Executable part }

Subprogram SectionFunction 1 Function 2

Function 1 Function 2

Function 2



Function n
  1. The documentation section consists of a set of comment lines giving the name of the program, the author and other details, which the programmer would like to use later.
  2. The link section provides instructions to the compiler to link function from the system library.
  3. The definition section defines all symbolic constants.
  4. There are some variables that are used in more than one function. Such variables are called global variables and are declared in all the user-defined functions.
  5. Every C program must have one main( ) function section.
    This section contains two part, declaration part, and executable part.
    The declaration part declares all the variables used in the executable part. There is at least one statement in the executable part.
    These two parts must appear between the opening and the closing braces. The program execution begins at the opening brace and ends at the closing brace.
    The closing brace of the main function section is the logical end of the program. All statements in the declaration and executable parts end with a semicolon.
  6. The subprogram section contains all the user-defined functions that are called in the main function. User-defined functions are generally placed immediately after the main function, although they may appear in any order.

All sections, except the main function section, may be absent when they are not required.

Read This: Types of Data used in C Programming

Main() Function :

A  C  program is a collection of functions. The main function is essential. The program execution begins at the main function. The body of a function (or block) is enclosed in a set of curly braces { }. The following program is a working program in C. main ()


printf (“Welcome to All In One Tuts\n”);


( prinrf( ) function is a print function which sends data given to it to the standard display device.)

The above program when compiled and run gives the following output

Welcome to All In One Tuts