GitPedia

The c programming language 2nd edition solutions

Solutions to the exercises in the book "The C Programming Language" (2nd edition) by Brian W. Kernighan and Dennis M. Ritchie. This book is also referred to as K&R.

From ohkimur·Updated June 28, 2026·View on GitHub·

Solutions to exercises from **The C Programming Language** (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie, commonly known as **K&R**. The project is written primarily in C, distributed under the MIT License license, first published in 2018. Key topics include: c, c-language, c-programming, language, programming.

The C Programming Language 2nd Edition - Solutions

C/C++ CI

Solutions to exercises from The C Programming Language (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie, commonly known as K&R.

Getting Started

Prerequisites

You need a C compiler:

macOS:

shell
xcode-select --install

Ubuntu / Debian:

shell
sudo apt-get update && sudo apt-get install build-essential

Windows:
Use WSL (recommended) or MinGW.

Building

Build all exercises:

shell
make

Build a specific exercise:

shell
cd chapter_1/exercise_1_01 make hello_world ./hello_world

Clean up:

shell
make clean

Repository Structure

chapter_N/
  exercise_N_XX/
    solution.c      # Solution source code
    file_in.txt     # Input file (if needed)
    file_out.txt    # Output file (if needed)

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

Quick start:

shell
make format # Format your code make check # Run all checks before submitting

About the Book

The C Programming Language is a classic programming book. The exercises are designed so that you can solve them with the knowledge acquired up to that point in the book.

These solutions are meant to help those learning C. If you're working through the book, try solving the exercises yourself first!

Tools

License

This project is open source. Feel free to use these solutions for learning!

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from ohkimur/the-c-programming-language-2nd-edition-solutions via the GitHub API.Last fetched: 6/28/2026