mardi 20 novembre 2018

why logical and with change of order give different output?

        #include<iostream>
        using namespace std;
        int main(){

        cout<<-1&&0; //output is -1

        cout<<0&&-1; //output is 0
        return 10;

        }

i completly understand second output but unable to understand first output.As in second output and first operand is 0 then it dont evaluate 2nd operator and give 0 but in first it evaluate-1(which is true as it is non zero) then it has to evaluate 0 and give 0 as result not -1

Aucun commentaire:

Enregistrer un commentaire