HELP ! cant understand this.

ARR[L]+=L
ARR[L]*=L

what does this mean ?
Last edited on
See "Compound assignment" in the tutorial on operators.
http://www.cplusplus.com/doc/tutorial/operators/

a += b
means the same as
a = a + b
and so on.

ARR is an array.
ARR[L] is an element in that array using L as the subscript

Last edited on
Thats right,but what i want to know is how can we add or multiply a number (ie. index L here) to an array (here ARR[L]).what would it result in ?
how can we add or multiply a number (ie. index L here) to an array (here ARR[L]).what would it result in ?


Here's an example.

Imagine that the array ARR is this array of int values.

{ 1 , 3 , 84, 7 }

Imagine L is 2.

So what is ARR[L]? It's ARR[2], which is 84.

So what is ARR[L] * L ? It's 84 * 2, which is 168.

You are NOT adding or multiplying a number "to an array". You are adding or multiplying to one of the number inside that array.

Topic archived. No new replies allowed.