Problem 24. C Program to accept a year and check the given year is leap or not by using ternary
#include<stdio.h>
#include<conio.h>
main( )
{
int y,leap;
clrscr( );
printf(“enter any yr”);
scanf(“%d”,&y);
leap=(y%400= =0)?:(y%100!=0)?(y%4==0)?1:0:0;
if(leap= =1)
printf(“ the given year is leap year”);
else
printf(“given year is not leap year);
getch( );
}
C compiler: gcc 4.1.2
#include<stdio.h>
#include<conio.h>
main( )
{
int y,leap;
clrscr( );
printf(“enter any yr”);
scanf(“%d”,&y);
leap=(y%400= =0)?:(y%100!=0)?(y%4==0)?1:0:0;
if(leap= =1)
printf(“ the given year is leap year”);
else
printf(“given year is not leap year);
getch( );
}
C compiler: gcc 4.1.2
