C – Program Structure

Before we start the basic building blocks of the C programming language, we must know the Program Structure of C for the building of programs.

A C program basically consists of the following parts:

  • Preprocessor Commands.
  • Functions.
  • Variables.
  • Statement & Expressions.
  • Comments.

Let see the basic structure below to print Hello World:

 #include <stdio.h>

 int main() 
 {
  /* This is my First Program */
  // First Program
    printf("Hello, World! \n");
    return 0;
 }

Now, let’s know the various parts of the above example:

  1. #include <stdio.h> is a preprocessor command, the first line of the program that adds the stdio.h file before the program compilations.
  2. Next is int main() which is the main function where the program execution begins.
  3. /*...*/ or // is a comment box that will not be executed by the compiler.
  4. printf(...)is a function in C that displays the message “Hello, World!” on the screen. The message needs to be under " ".
  5. return 0; in a program terminates the main() function and returns the value 0.