Meet C++ and compile your first program
Write a small C++ program and identify the standard used in this track.
- Describe compilation and recognize the C++20 features used in the course.
C++ is a compiled, general-purpose language that grew from C and now includes classes, templates, and a large standard library. Source files commonly use .cpp. This track targets C++20, compiled with GCC 14 using -std=c++20 -Wall -Wextra. C++ has multiple standards (including C++11, C++14, C++17, C++20, and C++23); features and library support depend on the chosen standard and compiler.
1#include <iostream>
2
3int main() {
4 std::cout << "Hello, C++20!\n";
5 return 0;
6}Hello, C++20!
The compiler translates source code and links the program before it runs. #include <iostream> makes stream I/O declarations available, and std::cout writes to standard output. Code exercises compile and run with Compiler Explorer, a free public service; submitted source and test input are sent to it.
Key takeaways
This track uses C++20 with GCC 14.
Headers expose standard-library features.
Compilation catches many errors before execution.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write C++
Write C++20 in the editor and run it against sample input. GCC 14 compiles the code through Compiler Explorer, a free public service; your source and test input are sent there.
Print a greeting
Write a C++20 program that prints Hello, learner! followed by a newline.
- Greeting
Your code is compiled as C++20 with gcc 14 (-Wall -Wextra) and run on Compiler Explorer (godbolt.org), a free public service.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…