Lesson 2 – Hello World

First program in C:

#include <stdio.h>

main()

{

printf(“Hello World!”);

}

By this basic program, you can understand the structure of the C language program. As it is a procedural language, it is important to follow the structure, otherwise, errors will occur during compilation.

Header files must be included before writing the program. The header file is a collection of function definitions. We must include the header files of the functions which we need to include in our programs.

Some commonly used header files of the C language are:

  • Math.h
  • Conio.h
  • Stdio.h
  • String.h

Header files are included by writing, “ #include <stdio.h> “

Here #include is a preprocessor directive. It tells the compiler to include files in the program before compilation.

The second thing is to declare the main body. The syntax for declaring the main body is “ Void main (void)” OR “main()”

After the declaration of the main body, all the lines of code are written in curly braces{ }.