int arr[] = { 10, 20, 30, 40 };
for (int x : arr)
{
// Stuff with x
// x will first have 10, then 20 and so on.
}
for_each( InputIt first, InputIt last, UnaryFunction f );
//Example
vector<int> v{ 1, 2, 3, 4, 5 };
for_each(v.begin(), v.end(), [](int i) { cout<<i<<" "<<endl; });