Given an integer which represents the year, the task is to check if this is a leap year, with the help of Ternary Operator.

A year is a leap year if the following conditions are satisfied:

- Year is multiple of 400.
- Year is multiple of 4 and not multiple of 100.

Following is pseudo code

if year is divisible by 400 then is_leap_year else if year is divisible by 100 then not_leap_year else if year is divisible by 4 then is_leap_year else not_leap_year

Below is the implementation of the above approach:

`// C program to check if a given ` `// year is a leap year or not ` ` ` `#include <stdbool.h> ` `#include <stdio.h> ` ` ` `bool` `checkYear(` `int` `n) ` `{ ` ` ` ` ` `return` `(n % 400 == 0) ` ` ` `? ` `true` ` ` `: (n % 4 == 0) ` ` ` `? (n % 100 != 0) ` ` ` `: ` `false` ` ` `? ` `true` ` ` `: ` `false` `; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `year = 2000; ` ` ` ` ` `checkYear(year) ` ` ` `? ` `printf` `(` `"Leap Year"` `) ` ` ` `: ` `printf` `(` `"Not a Leap Year"` `); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

**Output:**

Leap Year

## Recommended Posts:

- Program to check if a given year is leap year
- How to Print the Next N Leap Years in Java?
- Largest of two distinct numbers without using any conditional statements or operators
- Ternary operator vs Null coalescing operator in PHP
- SQL | Conditional Expressions
- Conditional wait and signal in multi-threading
- Web Caching and Conditional GET Statements
- CSS | Conditional Rules
- C++ Program to concatenate two strings using Operator Overloading
- Program to Find the Largest Number using Ternary Operator
- C program to display month by month calendar for a given year
- How to calculate the Easter date for a given year using Gauss' Algorithm
- Program to find century for a year
- Java Program to Display Dates of a Calendar Year in Different Format
- Implement *, - and / operations using only + arithmetic operator
- Division without using '/' operator
- Addition of two number using '-' operator
- Find the remainder when N is divided by 4 using Bitwise AND operator
- Why is programming important for first year or school students?
- Print the season name of the year based on the month number

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.