WHAT IS THE STRUCTURE OF 'C' PROGRAM?
As we all know 'C' is a high-level programming language used to write executable programs with logics and it is called MOTHER of all other programming languages. Today, we`ll learn how is a program written in C? with proper syntax or structure.
C programs or any other high-level programming language programs are written with the help of functions. Without any function no program can be written. It is essential that in every C program one function must have a name main. The main function is the very first function of a C program. It is the part of the program, from where the execution starts, which has the definitions of other functions and may access other functions of the program which are pre-defined. It is necessary that any other function definitions must be defined separately, either ahead of or after the main function.
for example:
#include<stdio.h>
main( )
ELEMENTS OF 'C' PROGRAMMING.
Elements are the necessary things that must be in a C program.
1: PREPROCESSOR COMMANDS:
2: FUNCTIONS:
3: VARIABLES:
4: STATEMENTS AND EXPRESSIONS:
5: COMMENTS:
EXPLANATION ABOUT HOW DOES THIS PROGRAM WORKS:
- Here, stdio.h is a header file (standard input output header file) and #include is command to use the code from the header file in our source code. When compiler encounters printf( ) function and doesn`t find stdio.h header file, compiler shows error.
- Every program starts from main( ) function.
- printf( ) is a library function to display output which only works if #include<stdio.h> is included at the beginning.
- return 0 is a function return type match to function definition.
Comments
Post a Comment
If you have any doubts, Please let me know.