jeudi 19 novembre 2020

2 is not greater than 3 but still this code is giving output in If statement [closed]

the given output shouldn't run as 2 is not greater than 3 but this code is giving the output.Even in enter code herethe book from where i took the code is saying it will not give output

class Exercise {
    public static void main(String[] args) {
        int x = 1;
        while (x < 10) {
            x = x + 1; // 1+1=2
            if (x > 3) { // 2 is not greater than 3 then how can this code give the 
                // following output?
                System.out.println("big x");
            }
        }
    }
}
           // output
           big x
           big x
           big x
           big x
           big x
           big x`
           big x

Aucun commentaire:

Enregistrer un commentaire