I'll show you three ways to loop through vector elements. The index loop uses for(int i = 0; i < v.size(); i++) and lets you access v[i] by position. This works when you need the index number for something.
The iterator loop uses for(auto it = v.begin(); it != v.end(); it++) and dereferences with *it to get each value. Iterators work with all STL algorithms. The range-based loop uses for(int x : v) and is cleanest when you just need to read values.
If you want to modify elements, use for(int& x : v) with a reference, or changes won't stick because x is a copy.