C Basic Program Structure

It is always useful to know about the different parts of the C program. It will be helpful for understanding the programs in upcoming chapters. Let us learn about the basic program structure of the 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.


int main()
   /* simple c program output */
   printf("Hello World! ");
   return 0;
Tutorials Class - Output Window

Hello World!

Description of the sections in the 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 the 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 the compiler.
printf()printf() is a function in C, which prints the text output on the screen.
getch()This is used to read any character input from the keyboard.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.