jeudi 8 mars 2018

How IF statement works with AND and OR?

Suppose that I have the following code in a generic language:

a = 1
b = 2
IF a == 3 AND b == 2:
  do something
ELSE:
  do something

If a == 3 is false the program wouldn't need to check the second part because always results false for any value of n.

In the same way with or:

    a = 1
    b = 2
    IF a == 1 OR b == 3:
      do something
    ELSE:
      do something

if a == 1 is true the program wouldn't need to check if b == 3 because is always true.

I want to know if the program stops in the first part in these cases.

Aucun commentaire:

Enregistrer un commentaire