Node:Expressions and operators, Next:, Previous:Scope, Up:Top



Expressions and operators

Thinking in C. Short strings of code.

An operator is a character or string of characters used as a built-in function. We have already experimented with one operator in C: the cast operator.

An operator is so called because it takes one or more values and operates on them to produce a result. For example, the addition operator + can operate on the values 4 and 5 to produce the result 9. Such a procedure is called an operation, and any value operated on (such as 4 and 5 in this example) is called an operand.

There are many operators in C. Some of them are familiar, such as the addition operator + and subtraction operator -. Most operators can be thought of as belonging to one of three groups, according to what they do with their operands:

The majority of operators fall into the first group. The second group is a subset of the first set; in this second set, the result of an operation is a Boolean value (a value of either true or false).

C has about forty different operators. The chief object of this chapter is to explain the basic operators in C. We will examine more complex operators in another chapter. (See Advanced operators.)