Introduction Structure of C-Language







 Structure of c language program:-

            To write programs in c, we should follow the basic structure of the c program. Structure of a C program includes various sections/parts. All these sections may or may not be used in all the programs, But to write complete C program that can be easily understood by programmers one should use some or all the sections based on the program complexity and functionality. Simple programs may use a few sections and complex programs may use all the sections of the program structure.

              To understand the concept let us begin with a sample program with only three sections.


1) DOCUMENTATION  SECTION:- Gives the aim of the program or double line comment(This should be between '/*this comments is used  for  understand    any programs easily or find debug's easily*/').

           Ex:-/* program of operating system*/



    *     '//'  this is used for single line comments.

          Ex:- //Area of triangle. 


    2)LINK SECTION:- To include header files.

          Ex:-#include <stdio.h>      

          Ex:-#include<conio.h>


    3)DEFINITION SECTION:- Define any    fixed value in this               section. Before Definition section we must use pre                     processer '#'  and end with ;  semicolon 

EX:-  #define pi=3.14;


    4)GLOBAL DECLERATION SECTION:- In this section we                   define  any statement then we can use that statement in         our  entire program. And again no need to define that                 statement in our local section

  

    5)MAIN FUNCTION SECTION:- Body of program.

          Ex:-     int main()

                      {

                       Printf(“Hello students”);

                       return 0;

                      }

       Key points:-

         *  In c language every line should end with             ';'                   (semicolon).

       *  Must include header file.

       *  Program should be with in {     ---------------

            ---------------------------------------

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

         Body of program should start with'{' and end with'}'.


   6)SUB PROGRAM SECTION:-  sub program section means            user defined function 

EX:-  int add(int a, int b)

        {

             a=10;

             b=20;

            printf("sum = %d",a+b);

       }



NOTE:- Here documentation section , definition section,                        global declaration section and sub program section                 are optional. But link section and main function are                   compulsory.

Comments

  1. Anna nuv Chala chakkaga explain chesav .. pakkana unte danda Vesi abhinandinchevadini..Chala bagundi Anna ma madam Cheppinadanikanna ikkada chadivinappude baga ardam ayyindi..exam lo Kuda choosi rase chance unte matram pakka ee website lone choosi rasta Anna 👍.😎✌️

    ReplyDelete

Post a Comment

Popular posts from this blog

Structure of C-Language