Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

The first C program - Hello World

We can start our first C program by printing "Hello World" as output. One we grow we can print multiple things on screen. Please follow our tutorial step by step to dive into C programming.


#include<stdio.h>

void main()
{
printf("Hello World");
}

Breakup of "Hello World" Program

#include - Whaterver starts with '#', it is processed by preprocessor and it is known as preprocessor directive.
< stdio.h > - header file is sorrounded by <> angular bracket. We can also use like "stdio.h" but angular bracket one is faster.
void - Here void is return type of main() function. Return type can be any data type.
main() - main() is a function which is must to execute any program. It is case sensitive.
{ } - These are called braces, opening and closing braces.
printf() - printf() is library function which is used to print somethign console.
Hello World - "Hello World" is string here; instead of this you can put any string.


void main()
{
printf("Hello World");
printf("\n Program by CppBuzz.com");
}

Here '\n' is known as single line character. It prints the text in new line.

Main() function returning int value

int main()
{
printf("Hello World");

return 0;
}

Here int is used inpalce of void. Since we have used int as return type so we have to return some it value from main() function.