C Online Compiler
Example: Leap Year Program in C using If else Statement
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Leap Year Program in C using If else Statement #include <stdio.h> int main() { int y; // y - Value of the year printf("----Enter the year----\n"); scanf("%d", &y); if (y % 400 == 0) { printf("\n%d is the leap year.\n", y); } else if (y % 100 == 0) { printf("\n%d is not the leap year.\n", y); } else if (y % 4 == 0) { printf("\n%d is the leap year.\n", y); } else { printf("\n%d is not the leap year.\n", y); } return 0; }
2008
Output
Clear
ADVERTISEMENTS