0% found this document useful (0 votes)
40 views7 pages

C++ Hello World Program Basics

Uploaded by

sambhavdwivedi48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views7 pages

C++ Hello World Program Basics

Uploaded by

sambhavdwivedi48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Basic of C++ : )

First Hello World Program : )


• // C++ program to display "Hello World"

• // Header file for input output functions


• #include <iostream>
• using namespace std;

• // Main() function: where the execution of


• // program begins
• int main()
• {
• // Prints hello world
• cout << "Hello World";

• return 0;
• }
1. #include
• This is a preprocessor directive. The #include directive
tells the compiler to include the content of a file in the
source code.
• For example, #include<iostream> tells the compiler
to include the standard iostream file which contains
declarations of all the standard input/output library
functions.
2. using namespace std;
• This is used to import the entity of the std namespace
into the current namespace of the program.
• The std namespace is huge. The alternative to this
statement is to specify the namespace to which the
identifier belongs using the scope operator(::) each time
we declare a type. For example, std::cout.
3. int main() { }
• The main() function is the entry point of every C++
program, no matter where the function is located in the
program.
• The opening braces ‘{‘ indicates the beginning of the
main function and the closing braces ‘}’ indicates the
ending of the main function.
4. cout<<“Hello World”;
• std::cout is an instance of the std::ostream class, that is
used to display output on the screen.
• Everything followed by the character << in double
quotes ” ” is displayed on the output device.
• The semi-colon character at the end of the statement is
used to indicate that the statement is ending there.
5. return 0;
• This statement is used to return a value from a function
and indicates the finishing of a function.

You might also like