Program to accept a year and check the given year is leap or not by using ternary - 100 Most Important C# Programs

100 Most Important C# Programs

24. Program to accept a year and check the given year is leap or not by using ternary

Code:

# 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( );

}





All materials on the site are licensed Creative Commons Attribution-Sharealike 3.0 Unported CC BY-SA 3.0 & GNU Free Documentation License (GFDL)

If you are the copyright holder of any material contained on our site and intend to remove it, please contact our site administrator for approval.

© 2016-2025 All site design rights belong to S.Y.A.