size(): It returns the number of elements in the vector.
File: stl_vector.h
Parameter: No parameters are required for this function.
Syntax:
vecName.size()
For Example:
vec ={1,2,3,4,5}
vec.size() = > It returns size of vector (i.e 5)
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){vector<int> vec = {1, 2, 3, 4, 5};cout << vec.size() << "\n";return 0;}
No comments:
Post a Comment