File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,5 @@ add_executable(AscciArt src/strings/ascii_art.cpp)
12
12
add_executable (Factorial src/factorial.cpp)
13
13
add_executable (ReverseString src/strings /reverse .cpp)
14
14
15
+ add_executable (Leap src/exercism/leap.cpp)
15
16
add_executable (Trinaries src/exercism/trinaries.cpp)
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ /* *
4
+ * A given year is leap when:
5
+ * - Evenly divisible by 4
6
+ * - No evenly divisible by 100
7
+ * - No evenly divisible by 400
8
+ *
9
+ * @param year Year to test
10
+ * @return Indicates if given year is leap
11
+ */
12
+ bool is_leap_year (int year) {
13
+ return year % 4 == 0 && year % 100 != 0 && year % 400 != 0 ;
14
+ }
15
+
16
+ int main () {
17
+ int year;
18
+
19
+ std::cout << " This program checks if a given year is leap" << std::endl;
20
+ std::cout << " Enter year to check: " ;
21
+ std::cin >> year;
22
+
23
+ if (is_leap_year (year)) {
24
+ std::cout << year << " is leap." ;
25
+ } else {
26
+ std::cout << year << " is not leap." ;
27
+ }
28
+
29
+ return 0 ;
30
+ }
You can’t perform that action at this time.
0 commit comments