Expressions and Statements

We have been using the terms expression and statement throughout these first few chapters, and now the time has come to study their meanings more closely. Statements form the basic program steps of C, and most statements are constructed from expressions. This suggests that you look at expressions first.

Expressions

An expression consists of a combination of operators and operands. (An operand, recall, is what an operator operates on.) The simplest expression is a lone operand, and you can build in complexity from there. Here are some expressions:

4
-6
4+21
a*(b + c/d)/20
q = 5*2
x = ++q % 3
q > 3

As you can see, the operands can be constants, variables, or combinations of the two. Some expressions are combinations ...

Get C Primer Plus®, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.