-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleapyearpractice.cpp
More file actions
41 lines (35 loc) · 944 Bytes
/
leapyearpractice.cpp
File metadata and controls
41 lines (35 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
using namespace std;
int main(){
// declare variables
int year;
int leap_year;
bool D4, D100, D400;
// take user input
cout << "Input a year (4 digits): " << endl;
cin >> year;
// boolean values
D4 = (year%4 == 0);
D100 = (year%100 == 0);
D400 = (year%400 == 0);
// determine if the year is a leap year
// if(D4 && !(D100 && !D400)){
// cout << "" << year << " is a leap year." << endl;
// }
// else {
// cout << "" << year << " is not a leap year." << endl;
// }
if (D4) {
// might be a leap year
if (D100 && !D400){
cout << "The leap year was skipped that year." << endl;
}
else {
cout << "That year is a leap year." << endl;
}
}
else {
cout << " That year is not a leap year." << endl;
}
return 0;
}