K&R Exercises

K&R Exercises

Work through every exercise in The C Programming Language without leaving your browser. Write your solution, submit it, and it's compiled and run against a set of tests, with any difference from the expected output highlighted line by line. When you're stuck, compare with a reference solution.

Begin the exercises

Why K&R

Written by Brian Kernighan and Dennis Ritchie, the creator of C, The C Programming Language is one of the most celebrated programming books ever written. It's short and precise, and it's known for its exercises: they build directly on the text, leave the edge cases to you, and are famously challenging. Solving them is one of the best ways to really learn C.

How it works

  • Pick an exercise and write your solution in the editor.
  • Sign in with Google to save your code as you type and submit it for testing.
  • Each submission is compiled with gcc -Wall -std=c17 and run against tests that supply input, command-line arguments and files.
  • See which tests pass, exactly where your output differs, and your submission history.

Architecture

  • Angular with server-side rendering and an Express API, hosted on Firebase App Hosting
  • Every submission runs in its own isolated Vercel Sandbox microVM with no network access and strict time limits
  • Firebase Authentication with Google sign-in, exchanged for an httpOnly session cookie so pages render already signed in
  • Firestore for your code, test results and submission history
  • Upstash Redis for rate limiting and anonymous totals
  • Firebase App Check with reCAPTCHA to protect the API
  • NgRx for state, CodeMirror for the editor and NG-Zorro for UI components

8 submissions across 1 user