Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question: 12 in the following code block, assume that the variables rai…

Question

question: 12
in the following code block, assume that the variables rainy and toocold are boolean.
if ((not rainy) and (not toocold))
{
display(\its a good beach day\)
}
which of the following are equivalent to the above code block?
if ((not rainy) or (not toocold))
{
display(\its a good beach day\)
}
if ((not rainy) and toocold)
{
display(\its a good beach day\)
}
if (not (rainy or toocold))
{
display(\its a good beach day\)
}
if (rainy and toocold)
{
display(\its a good beach day\)
}

Explanation:

Step1: Apply De Morgan's Law

De Morgan's Law states that $
eg(A\land B)=
eg A\lor
eg B$ and $
eg(A\lor B)=
eg A\land
eg B$.
The original condition is $(
eg rainy)\land(
eg tooCold)$.
By De Morgan's Law, $
eg(rainy\lor tooCold)=(
eg rainy)\land(
eg tooCold)$.

Answer:

The third option (IF (NOT (rainy OR tooCold)) { DISPLAY("It's a good beach day") } ) is equivalent to the given code block.