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

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

1 day ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

3 weeks ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

3 weeks ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or…

4 weeks ago

Autocomplete System Implementation

Build an autocomplete system that, given a query string s and a set of possible…

4 weeks ago

Job Scheduler Implementation

Design a job scheduler that accepts a function f and an integer n. The scheduler…

4 weeks ago