C++ Range Based for Loop
for (int i : myArray) { std::cout << i << std::endl; }
- The "for" keyword initiates the for loop.
- The variable "i" is used to store the current value from the array.
- The colon ":" is used to separate the variable from the array.
- "myArray" is the name of the array you want to loop through.
- The body of the loop, enclosed in curly braces, will execute for each element in the array.
- Within the loop, "std::cout << i << std::endl;" is used to output the current value of "i" followed by a line break.