Basic Structure of C Program

Basic Structure of C Program


In this page we understand the basic structure of C Program. Because C Programming Language is Procedural/Structural Oriented and it follows top-down approach.


The structure of C program is divided into number of sections given below in sequential order:
  1. Documentation Section illustrates about the program information like program name, author name, date & time of program development etc. This section is actually just for reader not for compiling hence this is always used as a comments. 
  2. Preprocessor Directives or Link Section illustrates about the preprocessor commands used in your program and processed these commands before the compilation process.
  3. Definition Section illustrates about the defining expressions like conditional and constant that will be used in complete program using this name and replace name with its defining value or expression result.
  4. Global Declaration Section illustrates about the global variable or function that can be accessible anywhere inside a program.
  5. Main Function Section illustrates about the section from where execution starts and also known as programming entry point for execution of a program. Program execution starts from main() function. 
  6. Variable Declaration Section illustrates about the section for declaring the variable inside the main() function section.
  7. Body Section illustrates about the lines of codes for programming inside the main() function section. Lines of codes are nothing but all programming statements of C Language.
  8. Subprogram or Function Definition Section illustrates about the function definition which is declared in declaration section and called inside the main() function section.
So I hope you can understand the complete structure of C Program but we can also understand with an example.

/*Program of Simple Interest, Author Name is Ankur, 
Date is 18/07/2020*/ 

#include<stdio.h>
#include<conio.h>

#define rate 5.0

float time;
float SimpleInterest(float, float);

void main()
{

float price,si;

printf("Enter the Price and Time for Simple Interest");
scanf("%f%f",&price,&time);
si=SimpleInterest(price,time);
printf("The Simple Interest is=%f",si);
getch();

}

float SimpleInterest(float price,float time)
{
return (price*rate*time)/100;
}

Pictorial Representation of Basic Structure of C Program-

Basic Structure of C Program
Basic Structure of C Program


Write the above code in C Programming editor and Compile it using alt+F9 and Run it using ctrl+F9.
  

No comments:

Post a Comment