Skip to content

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

Notifications You must be signed in to change notification settings

FrazTheWizard/TheCProgrammingLanguage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

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
Exercise 6-5 : hashtable undef
Exercise 6-5 : reimplement #define

7. Input and Output

Exercise 7-1 : argv[0]
Exercise 7-2 : arbitrary input
Exercise 7-3 : minprintf
Exercise 7-4 : minscanf
Exercise 7-5 : rewrite postfix calculator with scanf
Exercise 7-6 : file diff
Exercise 7-7 : find pattern in files or stdin
Exercise 7-8 : print files with formfeed
Exercise 7-9 : isupper - speed vs space

8. The UNIX System Interface

Exercise 8-1 : cat with syscalls
Exercise 8-2 : fopen and _fillbuf with bit-fields
Exercise 8-3 : flushbuf, fflush and fclose
Exercise 8-4 : fseek
Exercise 8-5 : fsize
Exercise 8-6 : calloc
Exercise 8-7 : malloc error checking
Exercise 8-8 : bfree

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published