Monday, 24 July 2017

Write a Program to determine whether the year is leap or not

Write a Program to determine whether the year is leap or not  

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

What is leap year ?

If 366 days in a year than is called a leap year.

A year can be checked whether a year is leap year or not by dividing the year by 4, 100 and 400. If a number is divisible by 4 but not by 100 then, it is a leap year. Also, if a number is divisible by 4, 100 and 400 then it is a leap year. Otherwise the year is not a leap year.

Code:


#include<stdio.h>
#include<conio.h>
void main()
{
int y;
printf("Enter The Year To Check ");
scanf("\n%d",&y);
if((y%400==0)||(y%100!=0)&&(y%4==0))
printf("\n%d Is Leap Year",y);
else
printf("\n%d Not A Leap Year",y);
getch();
clrscr();
}

Output:


Try it yourself.
If you have any problem you can tell me on comment box i will help you.
thanks.

Viral Programs

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

0 comments:

Post a Comment