← All lessons

K&R · Chapter 1 · Reference

Chapter 1: A Tutorial Introduction

Hello, world, tables, characters, and the first programs that talk to the machine.

You do not need to buy the textbook to follow along. Each lesson states the task in our own words. A copy helps if you have one but it is not required.

15th August 2026

Last updated on 8th September 2026

Author: Kulwinder Krishan

Chapter 1 is the on-ramp. You write small programs, compile them, and watch what the machine does with characters, numbers, and loops. You do not need to buy the textbook to follow along. Each exercise page states the task in our own words. If you have K&R (Second Edition) open beside you, the numbering matches so you can walk the same ladder.

What this chapter covers

Hello, world. A temperature table. getchar and EOF. Counting characters. Arrays. A first look at functions. By the end of this stretch you have used most of the language you need for the rest of the course — not as a catalogue, as programs you typed.

Work each exercise here, in order. If you have the book, read the surrounding prose as a companion. If you do not, these lessons still stand on their own.

Exercises on this site

These are Exercises 1-1 through 1-11, in order:

  1. Hello, world — 1-1
  2. Unknown escape sequences — 1-2
  3. Fahrenheit to Celsius table — 1-3
  4. Celsius to Fahrenheit table — 1-4
  5. Reverse temperature table — 1-5
  6. getchar() and EOF — 1-6
  7. The value of EOF — 1-7
  8. Count blanks, tabs, and newlines — 1-8
  9. Collapse runs of blanks — 1-9
  10. Make escapes visible — 1-10
  11. Test the word count program — 1-11

Later in Chapter 1

The book continues through exercise 1-24. Those walkthroughs will join this site one at a time. Until they are here, stay with the eleven exercises above — they are enough to finish this stretch of Chapter 1.

Next

Start with Hello, world.

Leave a comment

Comments coming soon — set the NEXT_PUBLIC_GISCUS_* env vars after enabling GitHub Discussions and Giscus.