Advertisement
avr39ripe

cppLogicalOpBasics

Jan 12th, 2022
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     const int daysInYear{ 365 };
  6.     const int leapYearTester{ 4 };
  7.     int year{ 2000 };
  8.     //bool isLeap{ year % leapYearTester == 0};
  9.    
  10.     std::cout << "Enter year number\n";
  11.     std::cin >> year;
  12.  
  13.     //std::cout << "In year " << year << " there are " << daysInYear + isLeap << " days\n";
  14.     std::cout << "In year " << year << " there are " << daysInYear + (year % leapYearTester == 0)  << " days\n";
  15.  
  16.     // all operations return true/false result so it is bool
  17.     // == equal
  18.     // != not equal
  19.     // > greater than
  20.     // < less than
  21.     // >= greater or equal
  22.     // <= less or equal
  23.     //
  24.     // ! - logical "NOT"
  25.     // or , || - logilal "OR"
  26.     // and , && - logical "AND"
  27.  
  28.  
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement