C Program Examples - 400+ tested C programs, all 91 K&R solutions, free quizzes

by•
Most C tutorial sites are full of void main(), gets(), and outputs nobody ever ran. Every program I ship is compiled with gcc -Wall -Wextra at zero warnings and actually executed — the output you read is the output I got. Inside: 400+ C programs, all 91 K&R exercises solved, 9 topic quizzes (150+ questions) synced with a free Android app, real gdb/Valgrind/Make/CMake guides, and interview prep with tested code. Free, no signup, 100/100 PageSpeed. Solo project since 2011, rebuilt in 2026.

Add a comment

Replies

Best
Maker
šŸ“Œ
Hi Product Hunt šŸ‘‹ I started c-program-example.com in 2011 as a place to dump the C programs I was writing. It grew, then sat half-abandoned for a decade — the kind of site with void main(), gets(), and Turbo C screenshots. You've seen a hundred of these. This year I decided to rebuild it properly, with one rule: nothing gets published unless it compiles with gcc -ansi -Wall -Wextra at zero warnings and actually runs. Every output in these rebuilt posts is a real captured run — the tooling guides (gdb, Valgrind, Make, CMake) were recorded in real Linux containers, and the interview answers all have tested code behind them. Full transparency: 180+ posts are rebuilt to this standard so far, and I'm still working through the old 2011-era archive — a few relics remain, and finding them is half the fun. This month I fixed a "password encryption" post that subtracted 0xFACA from each character (a value that doesn't even fit in a byte). A reader asked "what is 0xFACA?" back in 2012, and my reply then was "that's just a key." The honest answer took 14 years. Along the way it grew a free Android quiz app (155 questions, all content unlocked — ads support it, with a one-time remove-ads option) and complete solutions to all 91 exercises from K&R's first seven chapters — as far as I know the only compile-verified set of its kind online. It's free, no signup, no paywall. I'd love feedback — and if you find a program that doesn't compile, tell me and I'll fix it within the week. — Sandeepa

honestly the zero warnings with -Wall -Wextra thing really got me, that's basically unheard of in tutorial code. ran a couple of the k&r solutions and they actually compiled clean on my machine too.

Ā 
Thank you for actually running them — that's genuinely the best compliment this project can get. The zero-warnings rule came out of embarrassment more than discipline: the 2012 versions of these posts were full of void main() and conio.h, and once I started rebuilding I decided nothing goes live unless gcc -ansi -Wall -Wextra comes back silent and the output shown is from a real captured run. If a post ever throws a warning on your setup — newer gcc versions do surface new ones sometimes — tell me which one and I'll fix it within the week.

Sketches over here tend to be a wall of code with no context, so it's refreshing to see actual outputs next to each snippet. The K&R solutions being warning-free under `-Wall -Wextra` is the kind of thing I'd wish more tutorials cared about.

Ā 
Thanks Mara — the outputs are the part I'm most stubborn about. The giveaway on old tutorial sites (including mine, in 2012) was that posts showed code but no output, because nobody had ever actually run it. Now every output block is copied from a real run of the exact code in the post — if the program reads input, the sample session shown is a real session. It makes writing a post slower, but it means a reader can diff their result against mine and know immediately whether something's wrong on their end or mine.

Really appreciate that every program is actually compiled and tested — that's rare for C tutorials. Solving all 91 K&R exercises is a great resource. Congrats on launching!

Ā 
Thanks Zvonimir! The 91 cover chapters 1–7 completely — that leaves just the final chapter (8, the UNIX system interface), which is on my list. Every solution gets the same treatment: compiled with -ansi -Wall -Wextra, run, and the real output published with it. Appreciate you stopping by on launch day — and good luck with Pazi!