0
hi friends,whats the output of the code and how you trace it?
3 Respostas
+ 5
> What is the output?
You can fin it ou yourself if your run the code and check the console.
> How does the output come to be like that?
I think it gets clearer when you use the curly brackets on the if-statements:
int i=3;
if(!i) {
i++;
}
i++;
if(i==3) {
i+=2;
}
i+=2;
+ 2
Curly braces is used for multiline statements.
If there is no curly braces it means only single statement would be there
so
if(!i)
i++;
i++;
is like
if (!i)
i++;
i++;
+ 1
thanks Lisa , really illuminating.