First C Program

first program in c language

First C program to explain code and basic structure of C language.

#include<stdio.h>
int main()
{
	printf("Hello World Program");
	return 0;
}

Output : Hello World Program


Whenever we run this C language example, it will print Hello World Program as output. We will learn every line of the code step by step.

#include : This is called pre processor directive. It gives instruction to the compiler to include header file.

<stdio.h> : Standard Input Output header or library file includes some standard functions like printf(). Library functions or predefined functions are stored in a header file. So it must be included in C program before using any predefined functions.

#include<stdio.h> : Instruction for compiler to include header file stdio.h to use printf() function in C program. It must be first line or before main() function.

main() : main() is the first function called by the operating system as starting or entry point. All other functions must be called directly or indirectly in the main(). So, every C program must have main() function.

int main() : int before main() is called return type of function, we will discuss it later in function chapter.

{ } : The opening and closing braces { }, is starting and ending point of function and also called body of main() function. All statement must be within braces.

printf() : The printf() function is used to print anything on the output window. This library function is define in header file, That’s why we need to include this.

return 0 : It is success message for operating system. If the code return 0 means program worked fine and if it return non zero to operatting system, means exited due to error in C code.

Semicolon ( ; ) : Can you notice semicolon(;) at the end of printf(); and return 0; statement. It determines the end of statements, like full stop in the english langugae. Each C statement must be end with semicolon.