Skip to content

C practice

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

C is where printf, pointers and manual memory live, and the exercises here meet them one at a time. Your source is compiled by clang, running inside your browser via Emscripten, so warnings and errors are the compiler's real ones. Programs read from scanf and fgets using the input box, and the output panel shows exactly what your program printed — including the newline you forgot.

checked exercises
10
graded problems
0
lessons
8
cheat sheet
1

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 Loudprintf() puts text on the screen
  2. Name TagA variable is declared with a type, and holds one value under a name
  3. Party PlannerC does arithmetic with + - * / and %, and / between two ints throws away the remainder
  4. Umbrella or Notif/else chooses between two different blocks of code
  5. Countdowna for loop repeats a block a fixed number of times
  6. The Clapping GameAn if inside a for loop is decided again on every pass
  7. The Scoreboarda number between % and the conversion letter gives printf a fixed field width
  8. Packing ListAn array holds several values of one type in order, indexed from zero with []
  9. Rainfall WeekA variable declared before a loop carries its value from one pass to the next
  10. The Cafe TicketAssembling a complete program from parts you already know

C lessons behind the practice

All lessons →

C cheat sheet

Everyday syntax on one page, for when you remember the idea but not the spelling.

Coding interview questions

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

Questions people ask

Which C standard and compiler are used?
clang, built into the browser through Emscripten, compiling as C with the defaults a modern clang uses. If you want a specific standard flag, the C guide covers compiling locally with gcc or clang.
Can I use scanf and read input?
Yes. Whatever you type into the input box is the program's standard input, so scanf, getchar and fgets all work the way they do at a terminal.
Will undefined behaviour crash the page?
No. Your program runs in a sandboxed WebAssembly instance; an out-of-bounds write or a bad pointer can crash that instance, which is reported as a runtime error, but it cannot affect the page or your computer.
What comes next after these exercises?
Once the 10 exercises are done: 8 in-depth lessons, a cheat sheet for the syntax and the C++ path, which is the natural next language from here.

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.