C Structure

Structure of C Program

Before understanding the structure of 'C' program you must know these important points:
.'C' is a sensitive language,it means all the key words must be written in lower case.
.Key-words can't be used as variable or function name.
.Every instruction should be end with(;) sign
.Preprocessor directives(required) should be there in the beginning.
.Function main() is must for a program.
Now to write a program in 'C' just follow simple steps.
.Define preprocessor directives(include header files according to protype functions, standard I/O library functions to be used)
.Open function main()
.Assign data types and variables
.Define the body of the function
.End the function main()
/*harsh.c:first example for students*/
void main()
int a=10, b=15,c;
printf("Hello student ");
printf("the sum of %d and %d is %d",a,b,c);
In the above example the first line
/*harsh.c:first example for students*/
is a comment and non-executable.Comments in 'C' begins with(/0*) and ends with (*/).
Second line
is a preprocessor directive. The preprocessor processes the 'C' program before the compiler. Here stdio.h is header file consists of standard I/O functions. A header file related to the function used in program should be included at the beginning.
The Line
void main()
indicates"the beginning og the program".The compilation of the program
starts from main() function
{, symbol indicates the beginning of main() function.
The Line
int a=10, b=15,C;
is for declaration of variables and data types.
printf("Hello students ");
printf("The sum of %d and %d is %d",a,b,c);
are the body of the program
and symbol'}' indicates end of main() function.