You need to format your code properly, especially with regards to indentation. For example:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int lab1_array[9], i;
for (i = 0; i <= 9; i++) {
printf("Enter value : ");
scanf("%d", &lab1_array[i]);
}
for (i = 0; i <= 9; i++) {
printf("lab1_array[%d] = %d \n", i, lab1_array[i]);
}
return 0;
}
Next, raphaelriv's advice is sound. Generally, if you have an array of 9 elements and want to iterate over each element of the array in a "forward" direction, you would write:
Code:
for (i = 0; i < 9; i++)
Notice the use of < rather than <=.
But here you are required to have a 10 element array, so this declaration was wrong to begin with:
and subsequently your loop condition should be i < 10, not i < 9. This happens to be equivalent to i <= 9, but the i < 10 form is canonical when we start looping from i = 0.