C Program
/* C - Check Leap Year (short & working) */ #include <stdio.h> int main() { int y; scanf("%d", &y); printf((y%400==0 || (y%4==0 && y%100!=0)) ? "Leap Year\n" : "Not Leap Year\n"); return 0; }
C Output
Input:
2000Output:
Leap Year
C++ Program
// C++ - Check Leap Year (short & working) #include <bits/stdc++.h> using namespace std; int main() { int y; cin >> y; cout << ((y%400==0 || (y%4==0 && y%100!=0)) ? "Leap Year" : "Not Leap Year") << '\n'; }
C++ Output
Input:
1900Output:
Not Leap Year
JAVA Program
// Java - Check Leap Year (short & working) import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int y = s.nextInt(); System.out.println((y%400==0 || (y%4==0 && y%100!=0)) ? "Leap Year" : "Not Leap Year"); } }
JAVA Output
Input:
2024Output:
Leap Year
Python Program
# Python - Check Leap Year (short & working) y = int(input()) print("Leap Year" if (y%400==0 or (y%4==0 and y%100!=0)) else "Not Leap Year")
Python Output
Input:
2023Output:
Not Leap Year
In-Depth Learning – Entire Concept in Paragraphs
Social Plugin