+ 2
When i type this code (code is in description) i get answer 4232000 I want to know how i got it?
#include <iostream> using namespace std; int main() { int x[2][3] = {{2, 3, 4}, {8, 9, 10}}; cout << x[2][0] << endl; return 0; }
5 Answers
+ 9
You're accessing memory out of the array range, so you get a "random" memory value.
+ 9
an array starts from 0 not 1 remember
+ 4
Out of array they will return that value
+ 3
Possible outcomes:
x[0][0] = 2
x[0][1] = 3
x[0][2] = 4
x[1][0] = 8
x[1][1] = 9
x[1][2] = 10
x[2][0] is out of range
On VC++ you'll get a debug error instead of a random garbage.
- 1
I think that this is fun! âșâșđâșđđ