Categories: C++

Hello World program

Program code:

#include<iostream>

using namespace std;

int main()
{
    cout << "Hello World! \n Coderzpy.com!!\n\n";
    return 0;
}
Output:
Hello World! 
Coderzpy.com!!
  • #include<iostream>: A number sign (#) at the start of a line instructs the compiler’s pre-processor. The <iostream> header defines the libraries required to accept and output data.
  • using namespace std: This instructs the compiler to use the standard (std) namespace, which includes C++ Standard Library features.
  • int main(): C++, like any other programming language, begins program execution with the main function: int main ()
  • cout Statement: cout is used to print output to the screen. (This is similar to the printf statement in C.) The command cin >> is used to accept input from the terminal. (This is analogous to the scanf statement in C.)
  • return 0: The return type of the main method is int. As a result, in order to terminate the program, we must return 0.

Note: also read about Namespaces in C++

Follow Me

Please follow me to read my latest post on programming and technology if you like my post.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Share
Published by
Rabecca Fatima

Recent Posts

What is object oriented design patterns

A design pattern is a reusable solution to a commonly occurring problem in software design. They…

4 months ago

Factory Method Design Pattern in OODP

Factory Method is a creational design pattern that deals with the object creation. It separates…

4 months ago

Find Intersection of Two Singly Linked Lists

You are given two singly linked lists that intersect at some node. Your task is…

10 months ago

Minimum Cost to Paint Houses with K Colors

A builder plans to construct N houses in a row, where each house can be…

10 months ago

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file…

10 months ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order…

11 months ago