0
[SOLVED] Please make it easier to understand.
#include <iostream> using namespace std; int main() { int myArr[5]; for(int x=0; x<5; x++) { myArr[x] = 42; cout << x << ": " << myArr[x] << endl; } return 0; }
4 odpowiedzi
+ 2
The value 42 is assigned to every index from 0 to 4 of the array "myArr".
The cout is executed for every iteration and will result in an output like this-
0:42
1:42
2:42
3:42
4:42
+ 1
You havea an array of five elements with indexes from 0 to 4. In the for loop youa assign the value 42 to all of the elements one of a time than you print the index and the value witch will be:
0:42
1:42
2:42
3:42
4:42
0
What exactly don't you understand? Can you explain?
You have proceeded a bit into the tutorial. If you reached the third module, the part about arrays and such, you should be able to understand this.
So please tell us more about your problem, so that we can show you to the right place.
0
HonFu I want to understand after the for loop!