FANDOM


Hello, world Edit

Here is the "Hello, World!" program in C++:

Code Edit

#include <iostream>
 
int main()
{
  std::cout << "Hello, World!" << std::endl;
 
  return 0;
}

Explanation Edit

The first line in this program is a preprocessor directive, for inserting the iostream header. This header contains the necessary declarations and definitions for some basic input/output functionality.

The third line (int main()) starts the definition of a function called main. This function is called by the runtime library at program startup. The program will be terminated when we return from main. The int preceding the functions name indicates that main will return a value of type int.

In the fifth line, we use the cout object to write "Hello, World!" followed by line feed to the standard output stdout.

The return statement on the seventh line makes the main function return 0. The value returned from main is normally used as the exit value of the program, and a 0 normally means that there were no errors.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.