C Program Structure


#include< stdio.h>
#include< conio.h>
int main()
 return 0;

Various parts of the above program

  • The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation.
  • The next line int main() is the main function where program execution begins.
  • The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program.
  • The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen.
  • The next line return 0; terminates main()function and returns the value 0.

Different parts of C program.

  • Pre-processor
  • Header file
  • Function
  • Variables
  • expression
  • Comment

All these are essential parts of a C language program.


#include, the first word of any C program. It is also known as pre-processor. The main work of pre-processor is to initialize the environment of program, i.e to link the program with the header file.

Header file

Header file is a collection of built-in functions that help us in our program. Header files contain definitions of functions and variables which can be incorporated into any C program by pre-processor #include statement. Standard header files are provided with each compiler, and cover a range of areas like string handling, mathematical functions, data conversion, printing and reading of variables.

To use any of the standard functions, the appropriate header file must be included. This is done at the beginning of the C source file.

For example, to use the printf() function in a program, the line #include< stdio.h> is responsible.

main() function

main() function is a function that must be used in every C program. A function is a sequence of statement required to perform a specific task. main() function starts the execution of C program. In the above example, int in front of main() function is the return type of main() function. we will discuss about it in detail later. The curly braces { } just after the main() function encloses the body of main() function.

Compile & Execute C Program

Step 1: Open a text editor and add the above-mentioned code.

Step 2: Save the file as hello.c

Step 3: Open a command prompt and go to the directory where you saved the file.

Step 4: Type gcc hello.c and press enter to compile your code.

Step 5: If there are no errors in your code the command prompt will take you to the next line and would generate a.out executable file.

Step 6: Now, type a.out to execute your program.

Step 7: You will be able to see "Hello World" printed on the screen

Share this article on