fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int flags = 0b000001 | 0b010000;
  7.  
  8. std::cout << "Bit 1 is " << ((flags & 0b000001)? "set" : "not set") << ".\n";
  9. std::cout << "Bit 2 is " << ((flags & 0b000010)? "set" : "not set") << ".\n";
  10. std::cout << "Bit 3 is " << ((flags & 0b000100)? "set" : "not set") << ".\n";
  11. std::cout << "Bit 4 is " << ((flags & 0b001000)? "set" : "not set") << ".\n";
  12. std::cout << "Bit 5 is " << ((flags & 0b010000)? "set" : "not set") << ".\n";
  13. std::cout << "Bit 6 is " << ((flags & 0b100000)? "set" : "not set") << ".\n";
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Bit 1 is set.
Bit 2 is not set.
Bit 3 is not set.
Bit 4 is not set.
Bit 5 is set.
Bit 6 is not set.