Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.
(Hint: Use the % (modulus) operator)
void main()
{
int year;
printf("\nInput the year");
scanf("%d",&year);
if((year%4==0&&year%100!=0)||year%400==0)
printf("\nThe Year is a leap year");
else
printf("\nThe Year is not a leap year");
}
Subscribe to:
Post Comments (Atom)
Nice work
ReplyDeletecan you explain logic of this
ReplyDelete@prashant
ReplyDeleteduration of a solar year is slightly less than 365.25 days. Years that are evenly divisible by 100 are not leap years, unless they are also evenly divisible by 400, in which case they are leap years
1600 and 2000 were leap years, but 1700, 1800 and 1900 were not.
always try easy logic
ReplyDelete#include
int main ()
{
int year;
cout<<"Enter the year";
cin>>year;
if (year%4==0)
cout<<"Leap Year";
else
cout<<"Non Leap Year";
system("pause");
return 0;
}