Array?

Why is wrong with this code?


 
  a[j] = 2*a[j+1];


Here is the question
An array of int named a that contains exactly five elements has already been declared and initialized. In addition, an int variable j has also been declared and initialized to a value somewhere between 0 and 3.


Write a single statement that assigns a new value to the element of the array indexed by j. This new value should be equal to twice the value stored in the next element of the array (i.e. the element after the element indexed by j).

Here is the question
What exactly is your question?
Showing one line of code and asking what's wrong with it isn't really a valid question.
bigfern wrote:
Why is wrong with this code?


Nothing. (Provided the value fits inside an integer.)

Why do you think it is wrong?
Last edited on
Topic archived. No new replies allowed.