Hello Program
Hello Program
P R O G R A M
EXPL A N A T IO N
HELLO WORLD PROGRAM
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
HELLO WORLD PROGRAM
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
PREPROCESSOR DIRECTIVE
Preprocessor directive is an instruction given to the compiler before the
start of actual program. Preprocessor directive is also called compiler
directive.
The preprocessor directives are processed by a program known as
preprocessor. It is part of C compiler. It modifies C source program before
compilation.
The preprocessor directives start with hash symbol (#) and the keyword
include or define. These directives are written at the start of program.
Include Preprocessor directive
Define Preprocessor directive
INCLUDE PREPROCESSOR
The include preprocessor directive enables a program to access a
library.
The include preprocessor directive is used to include header files in
the program.
Syntax
int main()
{
printf("Hello world!\n");
return 0;
}
HEADER FILES
Header files are collection of standard library functions to perform
different tasks. There are many header files for different purposes. Each
header file contains different type of predefined functions.
Many header files can be included in one program. The header file must
be included in the program before calling any of its functions in the
program.
The extension of header file in C is .h. The include preprocessor
directive is used to include header file in programs.
The header files are normally stored in include subdirectory. The name
of header files is written in angle brackets < > or double quotation “ ”.
HELLO WORLD PROGRAM
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
MAIN FUNCTION
The main() function is the place where the execution of a C program
starts. When the program is executed, the control enter main() function
and starts executing its statements.
Each program must contain main function. If a program does not
contains main function, it can be compiled but cannot be executed.
Many number of statements can be written in the body of the main()
function. The body is enclosed in braces {}. The curly brace { is called
opening brace and } is called closing brace.
The braces are also known as delimiters.
HELLO WORLD PROGRAM
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
C STATEMENTS
A statement in C language is an instruction for the computer to perform a
task. A statement is a simple or compound expression that can actually
produce some effect. The statements are written in curly brackets.
Computer performs these instructions one by one in the same sequence in
which these instructions are written. Each statement in C is terminated
with semicolon.
printf("Hello world!\n");
This statement is used to print Hello world on output screen and \n is used
to move the cursor on next line.
HELLO WORLD PROGRAM
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
RETURN
The return statement causes the main function to finish.
Return may be followed by a return code (in our example is followed
by the return code with a value of zero).
A return code of 0 for the main function is generally interpreted as the
program worked as expected without any errors during its execution.
This is the most usual way to end a C console program.