← C++ from Scratch
Lesson 1 of 62 · 10 XP
Your first program
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
C++ is a compiled language, a descendant of C. You write main.cpp, the compiler (here clang++, right in the browser) translates it
into machine code, and only then does the program run. Everything C can do, C++ can do too, but it adds classes,
templates, a standard library (the STL) and lots of conveniences.
#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
return 0;
}
#include <iostream>— include the input/output streams library (std::cout,std::cin).int main()— the entry point, where execution starts. It returns an integer:0means "all is well".std::cout << "…"— print to the console.<<"pushes" data into the stream.\n— a line break. Every statement ends with;.
Task. Print two lines:
Hello, IGD!
I am learning C++
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.