C Programming Tutorial

Advertisements

Write a program to check whether a year is leap or not in C



       #include<stdio.h>
       #include<conio.h>
       void main()
       {

              int year;
              clrscr();
              
              printf("\nEnter year : "); 
              scanf("%d",&year);

              if(year%4==0 && year%100 !=0)
                     printf("\nThe given year is leap year.");              
              else if(year%400 == 0)              
                     printf("\nThe given year is leap year.");
              else
                     printf("\nThe given year is not leap year.");

              getch();
       }
       
   Output : 

              Enter year : 2012
              The given year is leap year.




Advertisement