Leap Year
Completed
Read a year and print leap or common.
Input
One integer.
Output
One word.
Example
Input
2024
Output
leap
Editor
C++
Hints
Store the condition in a bool, then use the conditional operator.
Solution explanation
Naming a condition with a bool variable makes code read like English.
Show solution
#include <iostream>
using namespace std;
int main() {
int y;
cin >> y;
bool leap = (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
cout << (leap ? "leap" : "common") << "\n";
return 0;
}