K&R C Chapter 3 Exercise Solutions — Control Flow

Chapter 3: Control Flow covers C’s branching and looping constructs. It is short (6 exercises) but the exercises are non-trivial: exercise 3-3 implements expand(s1,s2) to expand shorthand like a-z into the full alphabet; 3-4 handles itoa for the most negative integer (a classic overflow trap); 3-5 converts integers to arbitrary bases. These are worked solutions …

K&R C Chapter 2 Exercise Solutions — Types, Operators, and Expressions

Chapter 2: Types, Operators, and Expressions covers C’s type system and operators in depth. The exercises focus on bitwise manipulation — rotating bits, setting and clearing fields, counting set bits — and type-conversion edge cases. Exercise 2-9 (x &= (x-1) deletes the rightmost 1-bit) is a classic bit-manipulation trick worth memorising. These are worked solutions …

K&R C Chapter 1 Exercise Solutions — A Tutorial Introduction

Chapter 1: A Tutorial Introduction is where K&R C begins — and it moves faster than most C books. By exercise 1-8 you are counting characters by category; by 1-13 you are drawing histograms; by 1-22 you are folding long lines. The chapter uses only a tiny subset of C deliberately: loops, if/else, basic functions, …