Recap - Simple Logic
Part of the Fundamentals section of Coddy's C++ journey — lesson 25 of 74.
Challenge
BeginnerGiven the following code snippet, your task is to assign boolean values (true or false) to variables b1, b2, and b3 so that b4 evaluates to true.
The variable b4 is calculated using the following logic:
- It performs an AND operation (&&) between b1, b2, and the NOT of b3
- For b4 to be true, all parts of the AND operation must be true
Try it yourself
#include <iostream>
int main() {
bool b1 = ?;
bool b2 = ?;
bool b3 = ?;
bool b4 = b1 && b2 && (!b3);
std::cout << "b4 = " << b4;
return 0;
}All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsModulo OperatorIncrement/DecrementPost Increment/DecrementArithmetic ShortcutsComparison OperatorsString Comparison5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 33Variables Part 2
Type DeclarationNaming ConventionsRecap - Initialize VariablesType Casting Part 1Type Casting Part 26Decision Making
If StatementIf - ElseSwitch StatementConditional OperatorRecap - If ElseNested If - Else