Hello World! Program in C

In this example, you will learn how to print Hello world in c programming language?? 

In order to understand this example, you should have knowledge of Operators. If you don't know about operators the read this post "Elements of C"

Program to display Hello World for C:-      

  1. #include
  2. int main() {
  3. // printf() - It display the thing written inside of double quotes .
  4. printf("Hello World!");
  5. return 0;
  6. }

Output for the program will be:-

Hello, World!
    

 Description of the Hello World program:-


     #include:- It is a Pre-processive  directive which is used to process header files before the  actual  execution of the  program starts through the  main().

     :- it  is a standard input/output header file which is used to access the                    
      predefined functions like printf() and scanf().

     main():- it is a user-defined function from which the actual program execution starts.
     {}:- a pair of curly braces denote the starting and ending of function blocks.

     clrscr():- it is a predefined function which is used to clear the screen after each                        execution of the program.

  printf():- it is a predefined function that is used to print messages on the screen.


  How Hello World Program Works ??


In this program #include is a preprocessor directive that tell the compiler to include the functionality of stdio.h.

The header file stdio.h contains the function such as scanf () and printf() to take the input and display the output .

In case if you directly use the function like printf and scanf without mentioning the  headerfile stdio.h then the program will not compile and it will error .

Printf() is a library function that is basically used to send the text written inside the double quotes to the Output screen of c.

The return means we have nothing to return to main but , since we have used int so we have to return a value to the main and , hence we return 0.

How to Run a C- program ??

I personally use the Visual studio code for writing  C program but here, for Simplicity, we will start with Codeblocks.

If you are still confused on which compiler to use read this article Top Ide for C and C++ Developers - 2019"

Step 1:  Open the compiler and click on file -> new -> Empty file.




Step 2 : Type the program in the compiler.


Step 3: Click on save or press ctrl+s and it will ask for file name give it any name of your wish.




Step 4: Click on the build and then click on compile.



Step 5: Click on the build and then click on run.




Step 6: You can see the output of your program.




You can comment on us if you find anything inappropriate or you want to give more information for the topic described above.




















Hello World! Program in C Hello World!  Program in C Reviewed by Digital Roy on January 06, 2020 Rating: 5

No comments:

Powered by Blogger.