bool values : bool « Data Types « C++ Tutorial






#include <iostream> 
using namespace std;  
 
int main() { 
  bool b; 
 
  b = false; 
  cout <<  "b is " << b << "\n"; 
 
  b = true; 
  cout <<  "b is " << b << "\n"; 
 
  
  if(b) cout <<  "This is executed.\n"; 
 
  b = false; 
  if(b) cout <<  "This is not executed.\n"; 
 
  
 
  return 0; 
}
b is 0
b is 1
This is executed.
10 > 9 is 1








2.6.bool
2.6.1.bool values
2.6.2.A bool value can control the if statement
2.6.3.Outcome of a relational operator is a true/false value
2.6.4.Variable size of bool
2.6.5.The || Operator
2.6.6.The !(Exclamation mark) Operator
2.6.7.The && Operator (amplifier)
2.6.8.Output boolean variable as boolean literal or number
2.6.9.Use bool value to control a while loop
2.6.10.Logical operators.