c program to find the leap year or not

LEAP YEAR

// WAP to find out Year is leap or not (IF-ELSE)

void main ()
{
int a;
clrscr ();
printf ("Enter the Year: ");
scanf("%d",&a);
if (a%400==0)
{
printf ("\nYear is Leap");
}
else
{
printf("\nYear is not Leap");
}
getch ();
}

//WAP to find out Year is leap or not (switch case)


#include<stdio.h>
#include<conio.h>
int main ()
{
int a;
//clrscr();
printf ("Enter the Year: ");
scanf("%d",&a);
a=a%400;
switch(a)
{
case 0:
{
printf ("\n Leap Year");
break;
}
default:
{
printf("\n Not Leap Year");
break;
}
}
getch ();


// about leap year: http://www.infoplease.com/spot/leapyear1.html
 

No comments:

Post a Comment