Program Structure in C Language : Structure of C program
Before going to learn c programming we must know about the program structure in c. general design of a c program refers as a c program structure . In short we can say
that it is an sample format to know how to write code in c.
In c programming the program code has written in following format.
- Include
section
- Main
function section
- Variable
declaration
- Function
declaration
- Statements
- Comments
section
function section
declaration
declaration
Sample program
/* sample
program in c*/
#include
<stdio.h>
int
main()
{
Int a=10;
printf(a);
return 0
}
include section
include section contains different header files of c programming language. All the built in functions ,keywords, etc are embedded in the libraries. This section links program to the c libraries so necessary
functions can include in program.
Main function section
It is the entry point of c program. Program execution started from the main function. C program must have an main function in the program.
Variable declaration
Variable can be declared in main function and user defined functions also. According to where the variable is declared it is differentiate as global and local variable. We will see the difference between local and global variables in later sections.
Function declaration
We can declare any number of functions. The functions declared by the user are known as user defined functions. Functions devi code in multiple blocks so it simplifies the programming.
Statements
Statements refer as the code written other than variable declaration and function declaration. Some examples of the statements are if statements,for loop statements etc.
Comments
Comments are used for better understanding of the program. It is useful to give the explanation of
code. Comments are ignored by the compilers. You can put comments anywhere in the program.
In short in above lesson we saw the which contents are useful to write the code. We will see the more elements in later sections gradually.
Post a Comment