In the following program, I am defining two global arrays A and B of length 3 each.
In my program, I am outputting the first A[0], A[1], A[2] and A[3].
Note . A[3] does not exist, so I expected the program to output an error or say 1e291 or something ridiculous.
But instead it outputs B[0].
Why is this?
Thanks in advance .
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <math.h>
using namespace std;
// global variables
long double A[] = {700,200,90};
long double B[] = {6000000,100000000,133510};
int main()
{
cout<<"\n"<<A[0]<<"\n";
cout<<"\n"<<A[1]<<"\n";
cout<<"\n"<<A[2]<<"\n";
cout<<"\n"<<A[3]<<"\n";
system ("PAUSE");
return EXIT_SUCCESS;
}