The C Book: Chapter 1 Exercises

This section portrays the answers to the exercises found in the C Book, a textbook found online to refresh my abilities with the C programming language. This page links to the answers of exercises found in chapter one.

exercise 1.1
Type in and test Example 1.1 on your system.
exercise 1.2
Using Example 1.2 as a pattern, write a program that prints prime pairs, a pair of prime numbers that differ by 2, for example 11 and 13, 29 and 31.
exercise 1.3
Write a function that returns an integer: the decimal value of a string of digits that it reads using getchar. For example, if it reads 1 followed by 4 followed by 6, it will return the number 146.
exercise 1.4
Use the function that you just wrote to read a sequence of numbers. Put them into an array declared in main, by repeatedly calling the function. Sort them into ascending numerical order, then print the sorted list.
exercise 1.5
Again using the function from Exercise 1.3, write a program that will read numbers from its input, then print them out in binary, decimal and hexadecimal form.

Chapter 1 Exercises Github

Posted in The C Book