- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find a leap year using C language?
Leap year is a year that consists of 366 days. For every four years, we will experience a leap year.
The logic we will implement to find whether the given year by the user through the console is a leap or not −
if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))
If this condition is satisfied, then the given year is a leap year. Otherwise, it is not.
Example
Following is the C program to check leap year with the help of If condition −
#include <stdio.h> int main(){ int year; printf("Enter any year you wish
"); scanf(" %d ", &year); if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0))) printf("
%d is a Leap Year.
", year); else printf("
%d is not the Leap Year.
", year); return 0; }
Output
When the above program is executed, it produces the following result −
Enter any year you wish 2045 2045 is not the Leap Year.
- Related Articles
- How to find leap year or not in android using year API class?
- How to Check Leap Year using Python?
- C++ Program to Check Leap Year
- Program to check if a given year is leap year in C
- How to detect if a given year is a Leap year in Oracle?
- Checking for a Leap Year using GregorianCalendar in Java
- JavaScript program to check if a given year is leap year
- Golang Program to Check Whether a Given Year is a Leap Year
- Java Program to Check Leap Year
- Java program to find if the given number is a leap year?
- PHP program to check if a year is leap year or not
- Check if a given year is leap year in PL/SQL
- How to check whether a year or a vector of years is leap year or not in R?
- What do you mean by a leap year?
- How can we calculate the number of seconds in a leap year?

Advertisements