Program Structure

We have discussed the Hello World program before. Let's discuss it more briefly. From this explanation, we will know about the program structure of the C language.

Here are the following parts of the C program-

  • Processor Commands

  • Functions

  • Variables

  • Statements 

  • Expressions

  • Comments


Let's watch this Hello World program


#include <stdio.h>


int main() {

   /* This is my first hello world program in C */

   printf("Hello World! \n");


   return 0;




Hello World


  • In the first line, "#include<stdio.h>" is a preprocessor command that informs the compiler to include stdio.h before performing the whole compilation.

  • The next line is "int main()" which is the main function from where the program execution begins.

  • The next line inside /*.....*/ will be fully ignored by the compiler as this syntax is used to insert comments inside the C program.

  • There is a "printf()" in the next line that is a function used to print some statements in C language. If you write "Hello World" inside this function then it will usually print the Hello World statement in the C console.

  • We have used "return 0" in the next line that terminates the main() function and returns the appropriate value i.e. 0.


How to Compile and Execute C program

To get the result of the code we must need to compile and execute the program in C language. Let's see how to compile and run it in the C compiler.

  • Open the C compiler and write the above code in the console.

  • Now check the indentations and then save the file as "Hello.c"

  • Now click on execute from the above menu and it will print the output of the program in the output console.


If you are using a Text Editor then use the following steps.

  • Open the C compiler and write the above code in the console.

  • Save the file as "Hello.c"

  • Now open a command prompt and go to the directory where your file is saved.

  • Now type the following code


gcc Hello.c

  • Press enter to compile your code in a command prompt.

  • If there are no errors then it will generate the a.out executable file.

  • Type the following code to execute your program.


  • You will see the output in your console.


Hello World

If you are facing any error then please recheck your code and the path of the saved file you entered.