+ 4
still finding it difficult with the arrays in loops. Guess it wasn't explained better
3 Respuestas
+ 3
Lets take the example given by this app.
int myarray[5]; this line creates the array which is of dimension 5,which means it stores 5 values.
for(x=0;x<5;x++)
{
myarray[x] = 42;
}
Ok. The index is the position an element has in an array. You know the first index is 0 and so the last one
Is 4. We need a variable to store these values,thats why x was created,starting with value 0 to get the value of index 0.
Now the for loop.Since 0<5 ,the loop will access the array's index 0 and set the value to 42. 1<5 -> index 1 -> value42 and so on..
+ 2
look up other sources and learn from there, searching "Array Tutorial C++" in any search engine should bring up useful results
+ 2
thanks guys. I'm getting much better now