Writing the First C++ Program — Hello World

"Hello World" is the simplest of program you can write in C or C++. If you're getting started learning C++ you should start with this short program. Write a program to print "hello world" in C or C++

The "Hello World" program is the simplest program one can write in a programming language. It is the very first step towards learning a programming language. In this short guide, we'll learn to build a simple "Hello World" program.

Purpose

Write a program to print " Hello World " in console.

#include <iostream>

using namespace std;

int main()
{
    printf("Hello World!");

    return 0;
}
Output
Hello World!

Explanation

The Hello World program is simple, it just displays Hello World text in console. The program requires the iostream header file as the printf() function is defined within it. The printf() function prints whatever string argument is fed into it. Thus feeding a "Hello World!" string outputs Hello World! in the console.