I would expect this code to print
0 1 2 3 4 5 6 7 8 9
but it only prints the first two elements of the array:
0 1
I realize I could just change the condition in my for loop to i < 10 to get the desired output, but I want to understand how/whether I can use the value of an element of the array to set the condition.
Thank you!
code:
#include <stdio.h>
int main()
{
int array[10];
for(int i = 0; array[i] < 10; i++)
{
array[i] = i;
printf("%d ", array[i]);
}
}