Structure of C Language 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 tells the compiler to include information about the standard
input/output library. It is also used in symbolic constant such as #define PI
3.14(value). The stdio.h (standard input output header file) contains definition
&declaration of system defined function such as printf( ), scanf( ), pow( ) etc.
Generally printf() function used to display and scanf() function used to read value
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.
/*First c program with return statement*/
#include
int main (void)
{
printf ("welcome to c Programming language.\n");
return 0;
}
Output: welcome to c programming language.
Steps for Compiling and executing the Programs
A compiler is a software program that analyzes a program developed in a particular
computer language and then translates it into a form that is suitable for execution on a particular computer system. Figure below shows the steps that are involved in
entering, compiling, and executing a
computer program developed in the C programming language and the typical Unix
commands that would be entered from the command line.
ALSO SEARCH:
"structure of c language program"
"basic structure of c language program"
"describe the structure of c language program"
"explain the structure of c language program"
"define structure of c language program with example"
"program for array of structure in c language"
"what is the structure of programming language"
"what is basic structure of c program"
"structure of c program with examples"