Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- // 1 2 3 4 5 6 7 # 8 9 10 11 12
- // 31 28 31 30 31 30 31 # 31 30 31 30 31
- // (month < 8) (month >= 8)
- // (month % 2 != 0) (month % 2 == 0)
- //((month < 8) and (month % 2 != 0)) or ((month >= 8) and (month % 2 == 0))
- int main()
- {
- int month{ 5 };
- int daysInMonth{30};
- std::cout << "Enter month number from 1 to 12\n";
- std::cin >> month;
- daysInMonth += (((month < 8) and (month % 2 != 0)) or ((month >= 8) and (month % 2 == 0))) + ((month == 2)*(-2));
- std::cout << "There are " << daysInMonth << " days in " << month << " month\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement