liveBook · Manning

Chapter 7: Functions

What you will learn in chapter 7 of Modern C, Third Edition

The chapter introduction contrasts conditional and unconditional control transfer and explains why functions are useful for organizing C programs.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduction contrasts conditional and unconditional control transfer and explains why functions are useful for organizing C programs.

Key terms: conditional execution, unconditional transfer of control, run-time data, functions, code factorization, code reuse, modularity, function arguments, return types, interfaces

7.1 Simple functions

This section explains how function prototypes guide calls and how a function’s returns must match its declared return type.

Key terms: prototype, parameter type list, return type, void, arguments, signed int, double, return statement, non-void return type, return value

7.2 main is special

This section explains main’s portable forms, how it reports termination status, and how it receives command-line arguments.

Key terms: main, entry point, prototype, runtime system, official forms, return value, EXIT_SUCCESS, EXIT_FAILURE, exit, status parameter

7.3 Recursion

The section uses recursive gcd and Fibonacci functions to explain how calls keep separate local state, why recursion needs termination, and how algorithm choice affects performance.

Key terms: recursion, recursive, local variables, function parameters, gcd2, remainder, termination condition, infinite recursion, precondition, assert

7.4 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 6: Derived data types Chapter 8: C library functions →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.