0
Why this code outputs 1 ?
#include <iostream> using namespace std; int main() { int n = 0 ; int a[] = {3, 4} ; n++ ; a [n] = n ; cout << a[1] ; return 0; }
2 Antworten
0
because a[n] = n means a[1] = 1
0
You are setting the object gotten in the a[n] index the " n " value that after "n++" becomes 1.
So the machine understand this : a[1] = 1
Finally you print out " a[1] " that after the setting is 1