How to Iterate Through a Vector Without Using Iterators in C++? Last Updated : 15 Jul, 2025 Comments Improve Suggest changes 17 Likes Like Report In this article, we will learn how to iterate through the vector without using iterator in C++.The most efficient method to iterate through the vector without using iterator is by using traditional for loop. It accesses all the elements using index starting from 0 to vector size() - 1. Let’s take a look at an example: C++ #include <bits/stdc++.h> using namespace std; int main() { vector<int> v = {1, 4, 6, 7, 9}; // Iterating through vector for (int i = 0; i < v.size(); i++) cout << v[i] << " "; return 0; } Output1 4 6 7 9 Explanation: In the above code, we provide the index in the vector operator[] using traditional for loop to iterate through the vector.There is also another method to iterate through vector without using iterator in C++.Using Range Based for LoopThe range-based for loop is a simple and concise way to iterate over the elements of a vector without asking for any iterator or index. (though internally it uses iterators) C++ #include <bits/stdc++.h> using namespace std; int main() { vector<int> v = {1, 4, 6, 7, 9}; // Iterating through vector for (auto i : v) cout << i << " "; return 0; } Output1 4 6 7 9 Comment S sarthak_eddy Follow 17 Improve S sarthak_eddy Follow 17 Improve Article Tags : C++ cpp-iterator STL CPP-Library cpp-vector cpp-containers-library cpp-map Traversal CPP Examples +5 More Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like