Q13 Any year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||

Any year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||

Program: 81

Any year is entered through the keyboard, write a c program to determine whether the year is leap or not. Use the logical operators && and ||

#include<stdio.h>
#include<conio.h>
int main()
{
    int year;
    printf("Enter the year: ");
    scanf("%d", &year);

    if((year%4==0 || year%400==0) && (year%100!=0))
    {
        printf("%d is leap year", year);
    }
    else
        printf("%d is not a leap year", year);

}

Output:

 Enter the year: 2014
2014 is not a leap year

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.