|
|
|
||||||
To manipulate the first element, we
will use the index zero as x[0] and so on.
The arrays look like in the memory as follows:
In the above program, we have
declared an array named x. ‘x’ is an array’s name but there is no
variable x. ‘x’ is not an lvalue. If some variable can be written on the left- hand
side of an assignment statement, this is lvalue variable. It means it
has some memory associated with it and some value can be assigned to it. For
example, if we have the code int a, b; it can be written as b = 2; it means that put 2 in the
memory location named b. We can
also write as a = b; it means
whatever b has assign it to a, that is a copy operation. If we
write as a = 5; it means put the
number 5 in the memory location which is named as a. But we cannot write 2 =
a; that is to put at number 2 what ever the value of a is. Why can’t we do that?
Number 2 is a constant. If we allow assignment to constants what will happen?
Suppose ‘a’ has the value number 3.
Now we assigned number 2 the number 3 i.e. all the number 2 will become
number 3 and the result of 2 + 2
will become 6. Therefore it is not allowed. |
||||||||
|
BACK |
HOME |
NEXT |
|||||