initialize vector with 0 c++ code example
Example 1: how to initialize vector in c++ with all elements 0
vector<int> arr(10,0);
Example 2: initialize all elements of vector to 0 c++
vector<int> vect1(10); //number of elements in vector
int value = 0;
fill(vect1.begin(), vect1.end(), value);
Example 3: c++ initialize a vector
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main()
{
// This vector initializes with the values: 10, 20, and 30
vector<int> vect{ 10, 20, 30 };
return 0;
}