Skip to main content

C Programming for Beginners #2 (First Program hello world)




  • This is the First C Program from which every programmer have started.
#include<stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}

Explanation of the Program
  1. include is to add the specific library to compile the program.
  2. In this case stdio.h is the library in which commands are predefined it is called as preprocessor directive.
  3. printf is used when we have to display something on screen.
  4. In printf \n is used to print on the new line.
  5. After every end of command ; is used.
To compile the C program there are many compilers available but if you ask me I compile and run my programs on ubuntu so in ubuntu the program is typed in text editor and saved it as .c file and in terminal it is compiled by two ways using gcc name.c and in place of name you have to enter the name of file you have saved.

It will give the compiled program as a.out and you can run it by ./a.out command

Note:- To give your program the name you want instead of gcc you can use make name command to compile your program.

Comments