In this article, we show two programs. In the first program, the array is not initialized. In the second program it is initialized to a value 0.
#include<iostream>
using namespace std;
int main(){
const int size = 10;
int a[10];
cout<<"The elements are "<<endl;
for(int i=0;i<size;i++){
cout<<a[i]<<endl;
}
return 0;
}

The output of the above program gives garbage values.
In the second program,one value is initialized to 0 and hence all the values are 0.
#include<iostream>
using namespace std;
int main(){
const int size = 10;
int a[10]={0};
cout<<"The elements are "<<endl;
for(int i=0;i<size;i++){
cout<<a[i]<<endl;
}
return 0;
}
