Demonstrate bool values. : Bool « Data Type « C++






Demonstrate bool values.

Demonstrate bool values.


 
#include <iostream> 
using namespace std;  
 
int main() { 
  bool b; 
 
  b = false; 
  cout <<  "b is " << b << endl; 
 
  b = true; 
  cout <<  "b is " << b << endl; 
 
  
  if(b)                               // control the if statement 
     cout <<  "This is executed.\n"; 
 
  b = false; 
  if(b) 
     cout <<  "This is not executed.\n"; 
 
  // outcome of a relational operator is a true/false value 
  cout <<  "10 > 9 is " << (10 > 9) << endl; 
 
  return 0; 
}

           
       








Related examples in the same category

1.Define and use bool valueDefine and use bool value