Identify the error in the following C statement
int x, i; for (i = 0; i < = 8; ++i) x[i] = i;
Will the error be defected? If so when?
After the 8th iteration the following code will generate an error. This is because, the array x can store only 8 element which is the maximum size of it (in this example). But the for loop will execute for 9 times. Thus at the 9th iteration, code inside the loop will try to store the value of i into the 9th position of array x, which violates the array rule and will generate an error (Array index out of bounds error).