Structure of C program
Structure of c program:
1 ) Comment line
2) Preprocessor directive
3 ) Global variable declaration
4) main function( ) { Local variables; Statements; } User defined function } } Comment line It indicates the purpose of the program. It is represented as /*……………………………..*/ Comment line is used for increasing the readability of the program. It is useful in explaining the program and generally used for documentation. It is enclosed within the decimeters. Comment line can be single or multiple line but should not be nested. It can be anywhere in the program except inside string constant & character constant.
Preprocessor Directive:
#include
Global Declaration:
This is the section where variable are declared globally so that it can be access by all the functions used in the program. And it is generally declared outside the function :
main()
It is the user defined function and every function has one main() function from where actually program is started and it is encloses within the pair of curly braces.
The main( ) function can be anywhere in the program but in general practice it is placed in the first position.
Syntax : main()
{ …….. …….. …….. }
The main( ) function return value when it declared by data type as
int main( )
{
return 0
}
The main function does not return any value when void (means null/empty) as void main(void ) or void main()
{
printf (“C language”);
}
Output: C language The program execution start with opening braces and end with closing brace.
And in between the two braces declaration part as well as executable part is mentioned. And at the end of each line, the semi-colon is given which indicates statement termination.
Ex: Program to Display "Hello, World!"
Good work keep it up
ReplyDelete