Logical Operators Quiz


What is the difference between && and ||?

Show Answer

What is the value of num1 in the following?

num1 = 3
num2 = 2

if num1 % 2 == 0 || num2 % 2 == 0
    num1 = num1 + num2
else
    num1 = num1 - num2
end

Show Answer

What is the value of string1 in the following?

string1 = "bonjour"
string2 = "hola"
string3 = "hello"

if string1 > string3 && string2 > string3
    string1 = "ciao"
elsif string2 < string3 || string2 > string1 
    string1 = "hallo"
else
    string1 = "buna"
end

Show Answer