Program to Check Leap Year
Here you will get the program code of C++ program to check leap year. This is the basic example of if-else (conditional statement).
Example of C++ Program to Check Leap Year
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<iostream> using namespace std; int main() { int year; cout << "Enter a Year : "; cin >> year; if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) cout<<year<<" is a leap year"; else cout<<year<<" is not a leap year"; return 0; } |
Output
Enter a Year : 2004
2004 is a leap year
Check out our other C++ programming Examples