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

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago