Advertisement
dmilicev

leap_year.c

Feb 15th, 2021
695
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     leap_year.c
  3.  
  4.  
  5.     You can find all my C programs at Dragan Milicev's pastebin:
  6.  
  7.     https://pastebin.com/u/dmilicev
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. int is_leap_year(int year)
  14. {
  15.     return !(year % 4) && (year % 100 || !(year % 400));
  16. }
  17.  
  18. int main(void)
  19. {
  20.     int i;
  21.  
  22.     for(i=1997; i<2030; i++)
  23.     {
  24.         printf(" %d ", i);
  25.  
  26.         if( is_leap_year(i) )
  27.             printf(" is leap year. \n");
  28.         else
  29.             printf(" isn't leap_year. \n");
  30.     }
  31.  
  32.     return 0;
  33.  
  34. } // main()
  35.  
Advertisement
RAW Paste Data Copied
Advertisement