vector
C++ code to demonstrate 2D vector

C++ code to demonstrate 2D vector

// C++ code to demonstrate 2D vector #include <iostream> #include <vector> // for 2D vector using namespace…

Vector to Vector

Vector to Vector

// CPP program to initialize a vector from // another vector. #include <iostream> #include <vector> using n…

Array to Vector

Array to Vector

// CPP program to initialize a vector from // an array. #include <iostream> #include <vector> using namespa…

Alternative of push_back( ) function

Alternative of push_back( ) function

// CPP program to initialize a vector like // an array. #include <iostream> #include <vector> using namespa…

push_back( ) function in vector

push_back( ) function in vector

// CPP program to create an empty vector // and push values one by one. #include <iostream> #include <vector&g…

front( ) function in vector

front( ) function in vector

// CPP program to illustrate // Implementation of front() function #include <iostream> #include <vector> us…

Clear( ) function in Vector

Clear( ) function in Vector

#include <bits/stdc++.h> using namespace std; int main() { // Initializing a vector of string type vector<…

Sum in Vector ( Method - 2 )

Sum in Vector ( Method - 2 )

// CPP program to illustrate // Application of size() function #include <iostream> #include <vector> using …

Sum in Vector

Sum in Vector

// CPP program to illustrate // Application of empty() function #include <iostream> #include <vector> using…

Check if the vector is empty

Check if the vector is empty

// CPP program to illustrate // Implementation of empty() function #include <iostream> #include <vector> us…

pop_back( ) function

pop_back( ) function

// CPP program to illustrate // pop_back() function #include <iostream> #include <vector> using namespace s…

Add a number in a Vector

Add a number in a Vector

// CPP program to illustrate // push_back() function #include <iostream> #include <vector> using namespace …

Vectors with &

Vectors with &

// C++ program to demonstrate how vectors // can be passed by reference. #include <bits/stdc++.h> using namespace…

Vectors without &

Vectors without &

// C++ program to demonstrate that when vectors // are passed to functions without &, a copy is // created. #includ…