where an integer expression 5 in brackets specifies there are five float (floating-point)
elements in the array y []. The first value in the y array is referenced by y [0], the
second value in the y array is referenced by y [1], and the last element is indexed by
y [KÀ1].
Multidimensional arrays can be defined simply by appending more brackets contain-
ing the array size in each dimension. For example,
int matrix_a [4][2];
defines a 4Â2 matrix called matrix_a. The matrix array would be referenced as
matrix_a [i][j], where i and j are row and column indices respectively.
An array can be initialized when it is defined, or the values can be assigned to it using
program statements. To initialize the array at the same time when it is defined, the
values are specified in a sequence that is separated by commas and enclosed with braces.
For example,
float y [5] {1.0, 0.0, 0.0, 0.0, 0.0};
initializes a 5-point unit impulse response sequence in the floating-point array y [].
Arrays can also be assigned values by means of program statements. For example, the
following example generates an N-point unit impulse sequence.
for(k 1; k < N; k)
{
y [k] 0.0;
/* Clear array */
}
y [0] 1.0;
/* y(0) 1
*/
A more detailed discussion on arrays and loops will be given later.
C.2 Arithmetic and Bitwise Operators
Once variables are defined to be a given size and type, a certain manipulation (operator)
can be performed using the variables. We have discussed assignment operators in C.1.1.
This section will introduce arithmetic and bitwise operators. Logical operators will be
introduced later.
C.2.1 Arithmetic Operators
C supplies arithmetic operators on two operands: + (add), - (subtract), * (multiply), /
(divide), and % (modulus, integer remainder after division). The first four operators are
defined for all types of variables, while the modulus operator is only defined for integer
operands. C does not have an exponential operator. However, the library function
pow(x,y)may be used to compute x
y
. Note that in C, a pow(x,y)is an expression,
while a pow(x,y); is a statement. Thus c b+(apow(x,y)); is a statement. The
result of this statement would be that the result returned by the function pow(x,y)is
assigned to a and ba is assigned to c.
ARITHMETIC AND BITWISE OPERATORS
475