int main()
{
clrscr();
int x[3];
int n;
cout<<"Enter the array size= ";
cin>>n;
cout<<"Enter the elements for array= ";
for(int i=0;i<n;i++)
{
cin>>x[i] ;
}
for(i=0;i<n;i++)
{
cout<<"x["<<i<<"]="<<x[i]<<"\n";
}
getch();
return 0;
}
When m trying the same logic in c# then I got the right output as if I enter the size of array more than I initialize it gives the exception. But in c++ m not getting any type of error neither on compilation time nor at run time. But according to rule it should be give some error at run time in output if i give array size more than I initialize. And one thing more why it determine the 09 as two numbrs not single as 90 it shows it 0 and 9 at differect index as in output.


If you have an array:
And you try to write into an element that doesn’t exist:
Then this is an error. However, a compiler is not required by the C++ Standard to diagnose this error, and most do not. This is because it would require computation every time you accessed the array to determine whether you were within the array bounds.
Instead, it is up to the programmer to ensure that he/she uses the array correctly, by writing these bounds checks his- or herself. Then the checks are only performed when the programmer has deemed them necessary, and there are no wasted computations.
So: