K&R Study Questions

Try to answer questions from the study list as you read each chapter. Some test questions are likely to be derived from these study questions.

Running Code

You may find it helpful to compile and run code yourself. This can be done by:

  • Running on the board (You can modify your lab1 program, or copy your lab1 folder to another directory and use that)
  • Compiling and running in Linux (we have provided a playground directory where you can modify main.c, run make to compile, and then run using ./main.)
  • Manually compile a file using gcc: gcc studyQuestions.c, and then run the produced executable: ./a.out

In some of the provide code files, you will see individual sections of code surrounded by preprocessor macros:

#ifdef Q6
...
#endif

In this case, you will need to define Q6 to compile that code. You can do that using either of these techniques:

  • gcc -D Q6 ch2_studyQuestions.c
  • make CFLAGS=-DQ6

Chapters