Structure of a C program

C language does not actually follow any specific method of writing a program. It is a case sensitive language. All the statement must be written in lower case letters. The structure of a C program is shown in below figure.


Programming in C
img
  • • Comment line is a non executable statement. It describes the purpose of the program/ statement which is optional. Documentation to the program is made by adding remarks or comment lines enclosed in /* and * / wherever necessary.
  • • The header files or preprocessor directives give instructions to the compiler to include compiler options (#include).
  • • Symbolic constant and macro definition phase contains macro substitutions (#define) to substitute a constant for identifier and / or conditional (#ifdef) directives.
  • • The statement of main () function are enclosed in curly braces {}.
  • • Variables declared outside main () are called global variables, and they can be used in the main program block and sub program block.
  • • Variables declared inside main () are called local variables, and they are used only in the block in which they are declared. Subprograms /functions can also have local variables.

Every C program must have a main () function. The main () function is divided in to

  • • Declaration of local variables
  • • Statements

This function starts with an opening curly brace {and ends with a closing curly brace}.

To support modularity, the C program contains number of user-defined functions.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext