0% found this document useful (0 votes)
15 views

Hello Program

The document discusses the components of a Hello World C program including preprocessor directives like #include to access header files, the main function which acts as the program entry point, statements like printf to output text, and the return statement to exit the main function with a return code of 0 to indicate successful execution.

Uploaded by

shadowriser240
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Hello Program

The document discusses the components of a Hello World C program including preprocessor directives like #include to access header files, the main function which acts as the program entry point, statements like printf to output text, and the return statement to exit the main function with a return code of 0 to indicate successful execution.

Uploaded by

shadowriser240
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

HELLO W O R L D

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

#include <standard header file>


DEFINE PREPROCESSOR
The define preprocessor directive is used to define a constant.
It starts with the symbol #. it can be used anywhere in the program.
Syntax
#Define identifier value
#: It indicates the start of preprocessor directive.
Define: It is used to define a constant.
Identifier: It is the name of the constant.
Value: It represents the value associated with the
Example: identifier.
#define PI 3.141593
HELLO WORLD PROGRAM
#include <stdio.h>
#include
<stdlib.h>

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.

You might also like