C Basic Program Structure

It is always useful to know about the different parts of C program. It will be helpful for understanding the programs in upcoming chapters. Let us learn about the basic program structure of C language.

Basic Program Structure of C Language

Any C program mostly consists of the following parts:

  • Preprocessor Statements
  • Functions
  • Variables
  • Statements & Expressions
  • Comments

We will create a simple C program with minimum code & then explain each code block.

Description of the sections in above C program

#include <stdio.h> This is a preprocessor statement that includes standard input output header file (stdio.h) from the C library. By including header file, you can use many different functions such as printf()
void main() The execution of C program starts with main() function. “void” is the return type of the function. Every C program can have only one main function.
Braces {} Two curly brackets {} are used to group all code statements. This indicates begins & ends of the main function.
/* Comments */ Comments are just used to document or explain the code, to help others understand it. Everything written inside the command /*  */ will be ignored by compiler.
printf() printf() is a function in C, which print the text output on the screen.
getch() This is used to read any character input from keyboard.

Congratulations! Chapter Finished. Do you want to practice more?
Exercises & Assignments
  • No Content Found.
  • Interview FAQs
  • No Content Found.