One line C program to check if a given year is leap year or not

C Programming Language Decision Making of C Language (Article) Decision Making of C Language (Program)

9493

Program:

/* Program to find that entered year is leap year or not.
  Author: Atnyla Developer */
  
// One line C program to check if a given
// year is leap year or not

#include <stdio.h>
#include <stdbool.h>
 
bool checkYear(int year)
{
  // Return true if year is a multiple pf 4 and
  // not multiple of 100.
  // OR year is multiple of 400.
  return (((year%4==0) && (year%100!=0)) ||
           (year%400==0));
}
 
 
int main()
{
    int year;
    printf("Enter a year to be check \n");
    scanf("%d", &year);
 
    checkYear(year)? printf("Leap Year \n"):
                     printf("Not a Leap Year \n");
 
    return 0;
}

Output:

Output 1 
Enter a year to be check
2100
Not a Leap Year
Press any key to continue . . .


Output 2 
Enter a year to be check
2012
Leap Year
Press any key to continue . . .

Explanation:

One line C program to check if a given year is leap year or not

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.