avr39ripe

cppLogicalAndOrNotEx

Jan 12th, 2022 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     bool doorA{};
  6.     bool doorB{};
  7.     // A
  8.     //          X
  9.     // -    []  -   [] -
  10.     //          ^
  11.  
  12.     // B
  13.     //          X
  14.     //      -  [] -
  15.     //      -  [] -
  16.  
  17.     std::cout << "Enter doorA state [1/0 - open/close]\n";
  18.     std::cin >> doorA;
  19.  
  20.     std::cout << "Enter doorB state [1/0 - open/close]\n";
  21.     std::cin >> doorB;
  22.  
  23.     std::cout << std::boolalpha << "You reach dest point: " << (doorA and doorB) << '\n';
  24.  
  25.     // all operations return true/false result so it is bool
  26.     // == equal
  27.     // != not equal
  28.     // > greater than
  29.     // < less than
  30.     // >= greater or equal
  31.     // <= less or equal
  32.     //
  33.     // ! - logical "NOT"
  34.     // or , || - logilal "OR"
  35.     // and , && - logical "AND"
  36.  
  37.     // a    b   a or b
  38.     // 0    0   0
  39.     // 1    0   1
  40.     // 0    1   1
  41.     // 1    1   1
  42.  
  43.     // a    b   a and b
  44.     // 0    0   0
  45.     // 1    0   0
  46.     // 0    1   0
  47.     // 1    1   1
  48.  
  49.     // a    !a
  50.     // 1    0
  51.     // 0    1
  52.  
  53.     return 0;
  54. }
  55.  
Add Comment
Please, Sign In to add comment