lundi 29 mai 2017

if else condition with and operator

void main()
{
int i=4,j=12;
if(i=5 && j>5)
    printf("Hi!");
else
        printf("Hello!");
}

First of all,the output of the above code is Hi!.Acording to me it should show a syntax error as i=5 is an assingment operator not i==5,if i==5 then also it is false and should print Hello,but how could it print Hi?

Aucun commentaire:

Enregistrer un commentaire