Using memset keyword we can set 0 for all index of an array .
we can don it in two different way
1 .
int array[5] = {0,0,0,0,0};
2 .
#include<bits/stdc++.h>
using namespace std;
int main()
{
int array[5];
memset(a, 0, sizeof(a)); // This is the line where we set 0 as value for all index of the array
for(int i=0; i<5; i++){
cout<<" "<<array[i];
}
cout<<endl;
return 0;
}
we can don it in two different way
1 .
int array[5] = {0,0,0,0,0};
2 .
#include<bits/stdc++.h>
using namespace std;
int main()
{
int array[5];
memset(a, 0, sizeof(a)); // This is the line where we set 0 as value for all index of the array
for(int i=0; i<5; i++){
cout<<" "<<array[i];
}
cout<<endl;
return 0;
}