Hello World C program with explanation

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("\nHello World");
getch();
}

Output

Hello world c program, sample c program.
Hello World C program










Explanation of the program


The program starts with 2 header files stdio.h and conio.h. Stdio is the standard input/output library, it is used to get inputs form the user and to display the output to the screen. Conio is the console input/output library. Every c program must have a main function, the execution of the program starts from the main function and all the instructions included in it will be executed. clrscr() function is derived from conio.h file and it is used to clear the output screen before anything is displayed on it.
The Printf function is derived from stdio.h file and it is used to display the output to the screen, the text included in a double quotes will be displayed and the value of a variable can be displayed by typing the variable name without double quotes Eg- printf(name); here name is a variable and the value stored in it will be displayed to the output screen. Finally the getch() function is used to get an input character from the user, inorder to see the output of a program, this function is necessary.

No comments: