#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[4]={1,2,3,4};
for(int i=0; i<6; i++){
cout << arr[i]<<endl;
}
return 0;
}
I tried running this code in visual studio and I'm getting the output as:
1
2
3
4
4
4200976
After modifying it also, I'm getting arr[n] as the length of the array. So is it always true, and can we assume that it is the most optimised way to get the length of the array?