Hello World! in C

Hello, world is a simple program in C language for the reader should understand the basics of programming.

  1. Displaying Hello World in C
//This is a simple program to display a statement
//"Hello World!"

#include<stdio.h>
#include<conio.h>
void main()
{
printf("Hello World!");
getch();
}

OUTPUT:
Hello World!

Explanation of the above program :

  • The first line that starts with “//”, indicates the comment line.
  • The comments are written in a program for future reference of a programmer. The comments are neglected by the compiler
  • In comments you can write anything, it may be helpful to understand your program by somebody else or by yourself after you see the program after a long period
  • There is any statement that starts with the ‘#’ sign meant to be preprocessor(a preprocessor is a tool that works on the program before the compiler)
  • The next statement i.e. “#include<stdio.h>”,indicates the preprocessor to include a header file name stdio.h with the program written by the user
  • Our programs will definitely have some data to be taken from the user and to display some data on the monitor
  • Any program of C should have a main function(function is a set of statements to perform a given task).
  • In the statement void main(), then word “void” indicates that this function is not going to return any data to its caller function
  • The ‘scan()’ and ‘printf()’ are the functions to handle the input and output operations respectively.
  • The meaning of these words and the process required to perform for taking the input and displaying the output mentioned in the header file namely stdio.h
  • “printf()” function used to display data on the standard output device i.e. the monitor.
  • The statements given inside the brackets is in double quotes, then the data will be displayed as it is.
  • The getch() function is an in-built function used to accept input from the user. This makes the computer wait for the user and hence, makes to output screen available for the user until he presses a key.
Translate »