Structure of C Program

Advertisements

C Program Structure

Structure of C program includes the following : Documentation, Preprocessor, Constant Declaration, Global Declaration, main(), Subprograms.

Structure of C Language


           Documentation
       - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

           Preprocessor
       - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

           Constant Declaration
       - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

           Global Declaration
       - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

           main()
           {

              //body of main()

           }
       - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

           Subprograms
         Function1()
         Function2()
                |
                |
         FunctionN()
               
  • Documentation may includes the information about the program, author, date of creation of program, etc. as comments.
  • Preprocessor tells the compiler to execute function, defines in header file, before the execution of main().
  • In Constant Declaration section, we declare constant variables, we can't change the value of constant variables throughout the program and we must initialize constant variables with declaration.
  • In Global Declaration section, we declare global variables, global variables are those variables that can be accessed by all function in a program.
  • main() is the first function to get executed. The main() serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program. A program usually stops executing at the end of main.The execution of main() begins with opening brace and ends with closing brace.
  • The subprogram section consists all the definition of user-defined functions that are called in the main().

Related topics

Advertisement