Hello World
C++ is a high-level, general-purpose programming language created by Danish computer scientist Bjarne Stroustrup. First released in 1985 as an extension of the C programming language, it has since expanded significantly over time.
Let's start with a classic "Hello World".
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
This program prints "Hello, World!" to the console.
Includes
#include <iostream> // Include a header file from standard library
#include "../myheader.h" // Include a local custom header file
Includes are instructions to the preprocessor to include external code.
Comments
/*
This is a multi-line comment
spanning multiple lines.
*/
// This is a single-line comment.
Comments are used to write programmers' notes that is to be ignored by the compiler at build time.
As you see there, a line comment starts with double slashes //
, and a block one is wrapped by /* ... */
.
Code Challenge
Try to modify the code provided in the editor to make it print
Hello, C++! Here I am!
.
Loading...
> code result goes here