I have:
#include <iostream>
int main()
{
static int i, arr[10];
cout<<(i==0) && (arr[i]<0);
}
Which means that both i
and all of the elements oft
are automatically initialized with 0
. Why does this expression (i==0) && (t[i]<0)
returns true? Even this returns true:
#include <iostream>
int main()
{
static int i;
cout<<(i==0) && (i==1);
}
I got confused when I red this question which supposedly has the correct answer a:
- Given the declarations:
static int i, t[10];
and assuming that neither i nor t are explicitly initialized, the value of the expression
(i==0) && (t[i]<0)
(a) is 1
(b) is 0
(c) depends on the context