24.0k views
5 votes
Use a logical OR to write a more concise equivalent of the following code:

if(saleAmount >= 300)
cout << "Delivery available" << endl;
else
if(areaCode == LOCAL_CODE)
cout << "Delivery available" << endl;

User Ioleo
by
5.7k points

1 Answer

4 votes

Answer:

if(saleAmount >= 300 || areaCode == LOCAL_CODE)

cout << "Delivery available" << endl;

Explanation:

|| operator is known as the logical OR operator in C++. The logical OR operator returns True either one of the operands is True or both of them True. It returns false only when both of the operands are false. The above-written code will print Deliver available when the saleAmount is greater than or equal to 300 or the area code is equal to LOCAL_CODE.

User Rudolfson
by
5.2k points