0

How works this code?

#include <iostream> using namespace std; int main() { int x[10] = {1,2,3,4,5,6,7,8,9,10}; for(int y:x){ cout << y; } return 0; } How we use ale values of x?

10th Aug 2017, 12:21 PM
Alexik
Alexik - avatar
1 ответ
0
It's a range based for loop. It starts at the beginning of the array of x, gives the value to y. You then do whatever you want with y. Then it goes to the next value in the array and keeps going until it reaches the end of the array. Check out this for more: http://en.cppreference.com/w/cpp/language/range-for
10th Aug 2017, 1:07 PM
Dennis
Dennis - avatar