Skip to content

C++ practice

Practice C++ online: 10 exercises, graded problems and a playground

Each run compiles your C++ with clang — the same compiler behind Xcode and much of Linux — brought into your browser through Emscripten, then executes the resulting WebAssembly. Compiler errors are real clang errors, which is the point: reading them is half of learning C++. The toolchain is a sizeable one-time download, so the first Run takes longer than the rest.

checked exercises
10
graded problems
0
lessons
0
cheat sheet (coming)
0

C++ practice exercises

How the path works →

In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.

  1. Hello, Out Loudstd::cout sends text to the screen
  2. Name TagA variable is a named, typed place to keep a value
  3. Party PlannerC++ does arithmetic with + - * / and %
  4. Umbrella or Notif/else chooses between two different outcomes
  5. Countdowna for loop repeats an action
  6. The Clapping GameAn if inside a for loop, decided again on every pass
  7. The Scoreboardstd::setw and std::left/std::right line values up in columns
  8. Packing Liststd::vector holds many values in order, and a range-based for loop walks through them
  9. Rainfall WeekA variable made before a loop carries a running total from pass to pass
  10. The Cafe TicketAssembling a complete program from parts you already know

Coding interview questions

Original questions with full model answers, for when the practice is going somewhere specific.

Questions people ask

Is the code really compiled, or interpreted?
Compiled, by clang, on every Run. That is why a missing semicolon or a type mismatch is reported before anything executes, exactly as it would be on your own computer.
Why does the first Run take several seconds?
The compiler and its libraries are downloaded once — around 27 MB — and set up inside your browser. After that, compiles are quick and nothing is fetched again until you close the tab.
Can I read input with cin?
Yes. Lines typed into the input box beside the editor are what std::cin reads from, in order, when the program runs.
What is here after the beginner exercises?
After the 10 exercises: the C guide, which covers the same machine from one level down.

Practise another language

The same kind of practice hub exists for Python, JavaScript, TypeScript, Java, C, C#, Go, PHP, Ruby, SQL, R and Bash & the Shell.