Basic Syntax of C Programming

Last Updated Nov 1, 2015, 07:00:14 PM





Almost every program we write on a computer has different type of format. That format is called as Syntax . A syntax is a set of rules,principles, and processes that govern the structure of a program in any given computer language.

Now let us look at the basic syntax of c programming with hello world program in C

Hello World Program in C

Now let us understand the program structure of above C program.

Step 1

#include Every line that starts with # hash symbol in c language are processed by preprocessor. The preprocessor generally takes our program and produces other program which is also the output.

Step 2

stdio.h The .h file in the above program imports some external libraries/functions which required in our program. For example, we're using printf() function which is actually imported from the external library of .h header file. This statement or declaration is called header file.

Step 3

int main(void) The main function indicates the compiler to tell from where to start the program execution. The void statement inside the main function means main does not take any parameters.

Step 4

printf("Hello World") It is a standard function to print anything as output. A printf statement must end with a semicolon( ; )

Step 5

return 0The return statement is used to tell the operating system where does the program terminates?. The value we passed 0 means it has a successfull termination in the above c program.

With that I hope you understood how does the basic C program syntax would look like. You will learn more about it in the coming chapters. For practice, you try the below example programs.

Example C Program