/TheCProgrammingLanguage

My journey going through all the exercises in the popular book by Dennis Ritchie and Brian Kernighan

The C Programming Language - Exercises

My journey going through all the exercises in the popular book by Dennis Ritchie and Brian Kernighan

The C Programming Language

Table of Contents

1. Tutorial Introduction

Exercise 1-1 : hello world
Exercise 1-2 : escape characters
Exercise 1-3 : printf
Exercise 1-4 : celsius to fahrenheit
Exercise 1-5 : reverse for loop
Exercise 1-6 : getchar
Exercise 1-7 : EOF
Exercise 1-8 : count chars
Exercise 1-9 : reducing blank sequences to 1
Exercise 1-10 : tabs, backspace and backslash
Exercise 1-11 : test a program
Exercise 1-12 : print word per line
Exercise 1-13 : word length histograms
Exercise 1-14 : letter frequency histogram
Exercise 1-15 : fahrenheit to celcius
Exercise 1-16 : longest input line
Exercise 1-17 : lines over maxlen
Exercise 1-18 : remove trailing blanks
Exercise 1-19 : reverse
Exercise 1-20 : detab
Exercise 1-21 : entab
Exercise 1-22 : linefold
Exercise 1-23 : remove comments
Exercise 1-24 : syntax validator

2. Types, Operators and Expressions

Exercise 2-1 : type ranges
Exercise 2-2 : conditions without && or ||
Exercise 2-3 : hex to int
Exercise 2-4 : squeeze array
Exercise 2-5 : any matching chars
Exercise 2-6 : set bits
Exercise 2-7 : invert bits
Exercise 2-8 : rotate bits
Exercise 2-9 : count 1-bits
Exercise 2-10 : ternary operator

3. Control Flow

Exercise 3-1 : alternate while loop
Exercise 3-2 : switch
Exercise 3-3 : expand
Exercise 3-4 : itoa
Exercise 3-5 : itob
Exercise 3-6 : itoa with min width

4. Functions and Program Structure

Exercise 4-1 : rightmost pattern match
Exercise 4-2 : atof with scientific notation
Exercise 4-3 : extend calculator - modulus and negative
Exercise 4-4 : extend calculator - print, dup, swap, clear
Exercise 4-5 : extend calculator - sin, exp, pow
Exercise 4-6 : extend calculator - variables
Exercise 4-7 : extend calculator - push back string
Exercise 4-8 : extend calculator - single push back char
Exercise 4-9 : extend calculator - pushed back EOF
Exercise 4-10 : extend calculator - getline
Exercise 4-11 : extend calculator - static variable
Exercise 4-12 : recursive itoa
Exercise 4-13 : recursive reverse
Exercise 4-14 : macro swap

5. Pointers and Arrays

Exercise 5-1 : getint
Exercise 5-2 : getfloat
Exercise 5-3 : strcat
Exercise 5-4 : strend
Exercise 5-5 : strncpy, strncat, strncmp
Exercise 5-6 : rewrite appropriate programs
Exercise 5-7 : array vs alloc speed
Exercise 5-8 : multidimensional arrays
Exercise 5-9 : pointers vs indexing
Exercise 5-10 : expr on cmdline
Exercise 5-11 : modify entab/detab to have cmdline arguments
Exercise 5-12 : extend entab/detab with -m +n
Exercise 5-13 : tail
Exercise 5-14 : sort -reverse
Exercise 5-15 : sort -fold
Exercise 5-16 : sort -directoryorder
Exercise 5-17 : sort fields
Exercise 5-18 : dcl
Exercise 5-19 : undcl
Exercise 5-20 : expand dcl

6. Structures

Exercise 6-1 : getword
Exercise 6-2 : word count
Exercise 6-3 : line number count
Exercise 6-4 : word count decreasing order