liveBook · Manning

Chapter 2: The principal structure of a program

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

The introduction connects earlier C examples to larger programs and distinguishes a program’s syntax from its semantic parts.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction connects earlier C examples to larger programs and distinguishes a program’s syntax from its semantic parts.

Key terms: syntactical aspects, semantic aspects, grammar, declarative parts, definitions of objects, statements, real programs, structural elements, Listing 1.1

2.1 Grammar

This section identifies the textual elements that make up a C program and distinguishes their grammatical form from their meaning.

Key terms: grammar, special words, punctuation, brackets, separators, terminators, comments, /*…*/, C++-style comments, //

2.2 Declarations

This section explains what declarations tell the compiler, where some declarations come from, and how scope limits an identifier’s visibility.

Key terms: identifier, keyword, declaration, consistent declarations, type, function, array, indices, pointer, maybe_unused

2.3 Definitions

This section distinguishes declarations from definitions and shows how initialized objects, array elements, and functions are defined.

Key terms: declaration, definition, initialization, initializer, object, storage, designated, array, array positions, indices

2.4 Statements

This section identifies statements as the instruction-bearing part of the main function and introduces the kinds of statements discussed next.

Key terms: statements, identifiers, main function

2.4.1 Iteration

This section explains how a C for statement iterates over a domain and why its loop variable should be defined in the statement's initial part.

Key terms: for statement, domain iteration, loop body, loop variable, loop condition, iteration counter, initial part of a for loop

2.4.2 Function calls

This subsection explains how a function call transfers control and passes argument values, using printf as an example.

Key terms: function call, current function, called function, arguments, values, call by value, pass by reference, pointers

2.4.3 Function return

This section explains how return statements pass control back to callers, using main and printf to trace a small program’s execution.

Key terms: return, main, int, EXIT_SUCCESS, control flow, function call, process-startup routine, printf

2.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 1: Getting started Chapter 3: Everything is about control →

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.