60.6k views
3 votes
If the intQuantity and decPrice variables contain the numbers 3 and 15.75, respectively, the condition If intQuantity > 0 AndAlso intQuantity < 10 OrElse decPrice > 20 will evaluate to ____. a.Nob.Yesc.Trued.False

User DaveCS
by
6.3k points

1 Answer

4 votes

Answer:

C) True

Step-by-step explanation:

To see why this evaluates to "True" let's see this line of code in C++

#include <iostream>

using namespace std;

int main()

{

int intQuantity = 3;

int decPrice = 15.75;

if (intQuantity >0 && intQuantity <10 || decPrice>20){

cout<<"True";

}

else{

cout<<"False";

}

return 0;

}

The output from this program will be "True" because the condition if (intQuantity >0 && intQuantity <10 || decPrice>20) evaluates to true. The reason is because in programming the Logical Or ( | | ) evalutes to true when one or both conditions are true. In the question, although the condition decPrice>20 is not true, the first condition intQuantity >0 && intQuantity <10 is true, so the OR evaluates to true.

User Ryan Fitzgerald
by
5.6k points