x[4] has a value 2.5, when prefixed with “(int)” what happens is that you “cast” the resulting value into an integer thereby dropping the decimal part without doing any rounding-off to it. This is called “Type casting” or converting from one data type to another. In this case, the value of x[4] which is in “float” is converted into an integer.
The equation will become:
x[ (int)x[4] ] = x[ 2 ] = 6.0
1
solved Array Index Confusion