[SOLVED] Please make it easier to understand. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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; }

22nd Feb 2020, 10:33 AM
Manas Negi
Manas Negi - avatar
4 Answers
+ 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
22nd Feb 2020, 10:38 AM
Avinesh
Avinesh - avatar
+ 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
22nd Feb 2020, 10:38 AM
Gabriel Ilie
Gabriel Ilie - avatar
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.
22nd Feb 2020, 10:42 AM
HonFu
HonFu - avatar
0
HonFu I want to understand after the for loop!
22nd Feb 2020, 10:46 AM
Manas Negi
Manas Negi - avatar