-->

Tuesday, 3 April 2018

Basic structure of c program

Basic structure of c program 
Documentations (Documentation Section)
Preprocessor Statements (Link Section)
Global Declarations (Definition Section)
The main() function

body of main function 
 

{ // Start of c program

·      Local Declarations
·      Program Statements & Expressions 
       
             } end of c program
User Defined Functions

Documentations  : This section consists of comment lines which include the name of programmer, the author and other details like time and date of writing the program. Documentation section helps anyone to get an overview of the program.
Preprocessor Statements :  Its start with # symbol these statement are already stored in memory to provide reference to compiler during compilation of program
Example  #include< stdio.h>
           these is preprocessor directive that include standard input output header file.
              # include< conio.h>
             #include<math.h>
Global Declarations : Consists of function declaration and global variables.  The scope these variable is entire program (ie it can access entire program)

Main( )function
            Every c program starts its execution from main function its consist of two curly braces opening {  and closing braces } within it contain body of main function
This section contains two parts, declaration and executable part. The declaration part declares all the variables that are used in executable part.

User defined function :  A small code is written separately and executed when every user is required . It is similar to main function but difference name given by user not in built

example
              #include<stdio.h>   // preprocessor directive
             main()
            {    // start of program
                 
 printf(“ welcome to 1st year engg”);  // local & executable statement
             }     //end of program


No comments:

Post a Comment

Basic structure of c program