C++: Output

Example: Simple Output in C++

Below is an example of simple output in C++. The first line is a comment. The second line is a directive (#) interpreted by the preprocessor (before compilation). It instructs the preprocessor to include a section of standard C++ code, known as header iostream, that allows to perform standard input and output operations.

int main () declares a function (group of code) named main, which is a special function in C++ where the program begins. std::cout identifies standard character output, i.e. the computer screen in most cases. << directs the "Hello World!" to this.

	// Hello World in C++

	int main()
	  std::cout << "Hello World!";