0

Why does an array of size 5 shows a random number of 7digits when we print b[8]

I tried to change the default code. #include <iostream> using namespace std; int main() { int b[] = {11, 45, 62, 70, 88}; cout << b[0] << endl; // Outputs 11 cout<< b[3] << endl; // Outputs 70 cout<< b[8] << endl; return 0; } Waiting for answer

21st May 2019, 1:17 PM
Vikas Bawa
Vikas Bawa - avatar
1 Resposta
+ 4
Because if you shoot past an array, you hit another spot of computer memory, where something else may be stored. (Don't do it.)
21st May 2019, 1:21 PM
HonFu
HonFu - avatar