array<int, 5> values = {1, 2, 3, 4, 10};
// the type declaration below must be consistent with the array type
for (int x : values){ //we use a colon instead of in
cout << x << endl;
}
#include <iostream>
using namespace std;
int main() {
int num_array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (int n : num_array) {
cout << n << " ";
}
return 0;
}
for (<variable_declaration> : expression){
//statements
}
for(auto& i : arr)
cout << i << " ";