Hello World C Program:
This is a program to print “Hello World” message on screen.
#include<stdio.h>
void main()
{
printf("Hello World");
}
Output
Hello WorldExplanation
Now try to understand this program step by step.
1. #include<stdio.h>: First statement started with #, it is called pre-processor directive. We will learn about them thoroughly in later tutorials. #include<stdio.h> is used to include the stdio.h header file in our program. Header files contains the functions that we use in our program. Here we have used printf() function which is present in stdio.h header file.
2. void main(): Here main() is the function. A program always starts with the main() function and every program must have main(). Here void is the return type of this function. It means main() function will not return anything. The opening curly braces ({) and closing curly braces (}) shows the body of the function.
main() can also be called as a collection of statements.
3. printf(): Here printf() is another function. This is used to print the values on the screen. Its general form is
printf(“Statement you want to print on screen”);
4. Semicolon (;) is used for denoting the termination of statement. It is also called statement terminator in C Language.
0 comments:
Post a Comment