go to previous page   go to home page   go to next page hear noise
data[2] + data[6]

Answer:

23

data[2] contains a 14 and data[6] contains a 9, the sum is 23.


Arithmetic Expressions

The Array

An expression such as data[3] is called a subscripted variable. A subscripted variable can be used anywhere an ordinary variable of the same type can be used. Since data[3] contains an int it can be used anywhere an int variable may be used.

An arithmetic expression can contain a mix of literals, variables, and subscripted variables. For example, if x contains a 10, then

(x + data[2]) / 4

evaluates to (10+14) / 4 == 6. Here are some other legal statements:

data[0] = (x + data[2]) / 4 ;

data[2] = data[2] + 1;

// increment the data in cell 3 
x = data[3]++ ;       

data[4] = data[1] / data[6];

QUESTION 4:

Assume that the array holds values as in the picture. What will be the result of executing the statement:

data[0] = data[6] + 8;