+ 1

Output of C++ code

Hello, Can someone explain the syntax of this code and what it does? #include <iostream> using namespace std; int main() { int mat[2][2] = {{1,2},{3,5}}; cout << 0[1[mat]]; return 0; }

25th Jan 2021, 8:21 PM
Edward Finkelstein
Edward Finkelstein - avatar
4 Respuestas
+ 1
This is a two dimensional array and the code will print the first item from the second element. cout<<mat[1[0]];
25th Jan 2021, 8:30 PM
HBhZ_C
HBhZ_C - avatar
+ 1
HBhZ_C we could see that by running code... but why 0[1[mat]] == mat[1[0]] ?
25th Jan 2021, 8:33 PM
visph
visph - avatar
+ 1
Not equal but the right side of assignments is the used syntax in other languages .print the first(index 0) item from the second element or row ==>3 visph
25th Jan 2021, 8:37 PM
HBhZ_C
HBhZ_C - avatar
+ 1
not equals? but output same value ^^
25th Jan 2021, 8:39 PM
visph
visph - avatar