Basic Structure of C Program. (Explain with Example)



Everything you need to know about basic structure of a C program . OK Guys, Let's see. 








Basic structure of C program :-

The basic structure of C program implies the composition of a program. It's help understand to coding program. 










Documentation  Section:-

This section contains a set of comment lines giving the name of program, the author, algorithms, methods used and other details. The compiler won't compile this and hence this portion would not be displayed on the output screen. This section will be useful in future for users and developing teams. 
comments are be giving in C programming in two different ways. 

1. Single Line Comment = //
2. Multi Line Comment = /*...*/

For Example
//ellipse.c
/*This code once compiled and executed , calculates the area of an ellipse after reading major and minor axis*/
/*Program coded by Tiloc Thapa*/
    
/* = We are use this symbol to  start comment. 
*/ = We are use this symbol to closed comment.







Link Section:-


The link section provides instruction to the compiler to link functions from the system library. This section is also called the header declaration section. Header file in C is a file having .h extension. There are several built in C functions  like prinft(), scanf(), clrscr(), getch() defined in C library with as a header file having it's .h extension. 

For example:-

              #include<stdio.h> links input/output functions like printf()  and scanf() with the program. 





Definition Section:-

The definition section defines all symbolic constants. A symbolic constant is a constant value given to a name which can't be changed in program. 

Example:-

#define PI 3.14

In above code, the PI is a constant whole value is 3.14





Global Declaration Section:-


The global variables that can be use anywhere in the program are declared in global declaration section. This section also declares the user defined function.

Example:-

              float area(float r);
              int a=7;




Main() function section:-


It is necessary have one main() function section in every C program. This contains two parts declaration and executable part. The declaration part declares all the variables that are used in executable part. These two part must be written in between the opening and closing braces. Each statement in the declaration and executable part must end with a semicolon(;). The execution of program starts at opening braces and ends at closing braces. 

Example:-

         int main(void)
         {
         int a=10;
         printf("%d", a);
         return 0;
         }




Subprogram Section:-


The subprogram section contains all the user defined functions that are used to perform a specific task, these user defined functions are called in the main() function.






\Thank you guys,  I daily post about c programming language. This tutorials will be helpful to know about C language.\   Coming soon next topic
.

Comments

  1. Join our C Language Course in Delhi, where skilled instructors will guide you in mastering the basics of C programming, from data types and control structures to arrays, pointers, and functions. Through practical exercises and projects, you'll develop the ability to write C code and solve real-world problems.

    ReplyDelete
  2. Join us in Best Artificial Intelligence Course In South Delhi for an AI learning journey like no other. Master the skills demanded by the industry and stay ahead in technological innovation.

    ReplyDelete

Post a Comment

Popular posts from this blog

Learn C Programming Languages ( Definitions and Advantages).

Data Types in C (types and examples)