Logical Not Operator in C++
Level 265 keystrokes
Inverts the bool active (false) with the ! operator; !active is true, so Inactive is printed.
C++ code
// Declares the bool active and sets it to false1bool active = false;// ! (logical NOT) turns false into true and true into false// !active is true here, so the block runs2if (!active) { // Prints Inactive3 cout << "Inactive" << endl;4}Output
Inactive
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 4;× 2"× 2!× 1(× 1)× 1{× 1}× 1=× 1