Wednesday, July 18, 2012

Check for a leap year

, , No comments
Algorithm to check leap year.

if year % 400 is 0
          then is_leap_year 
else if year %100 is 0 
         then not_leap_year 
else if year % 4 is 0 
        then is_leap_year
else not_leap_year 





Source Code:
#include<stdio.h>
#include<conio.h>
   void main()
    {
        int year;
        
        printf("\n Enter A Year :: ");
        scanf("%d",&year);


       if(year%400==0 || year%4==0 && year%100!=0 )
       printf("\n Leap Year");


       else
       printf("Not Leap Year");
  
       printf("\n Log on to http://www.whatiLearn.info For More ");  
           getch();

     } 

Input: 

Enter A Year  ::2000

Output:

Leap Year
Log on to http://www.whatiLearn.info For More

0 comments:

Post a Comment

Entries RSS Comments RSS

Sample Text

Pages


Copyright © Lovely Codes
Powered by Blogger
Distributed By Free Blogger Templates | Design by N.Design Studio
Blogger Theme by Lasantha - PremiumBloggerTemplates.com