C++ Online Compiler
Example: C++ Program to Check Leap Year using If-else Statement
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ Program to Check Leap Year using If-else Statement #include <iostream> using namespace std; int main() { int y; // Value of the year cout << "----Enter the year----\n"; cin >> y; if (y % 400 == 0) { cout << "\n" << y << " is the leap year.\n"; } else if (y % 100 == 0) { cout << "\n" << y << " is not the leap year.\n"; } else if (y % 4 == 0) { cout << "\n" << y << " is the leap year.\n"; } else { cout << "\n" << y << " is not the leap year.\n"; } return 0; }
1997
Output
Clear
ADVERTISEMENTS