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