Skip to content
Snippets Groups Projects
Select Git revision
  • 47fbe2beac25a805511f2dca459d67e1e6859c88
  • master default
2 results

fhello-1.c

Blame
  • Forked from Peter Gerwinski / hp
    Source project has a limited visibility.
    loesung-2-f1.c 613 B
    #include <stdio.h>
    
    int IsLeapYear (int year)
    {
      if (year % 4)
        return 0;
      else if (year % 100)
        return 1;
      else if (year % 400)
        return 0;
      else
        return 1;
    }
    
    int main (void)
    {
      int ORIGINYEAR = 1980;
      int days = 366;
      int year;
    
      year = ORIGINYEAR;  /* = 1980 */
    
      while (days > 365)
        {
          if (IsLeapYear (year))
            {
              if (days > 366)
                {
                  days -= 366;
                  year += 1;
                }
            }
          else
            {
              days -= 365;
              year += 1;
            }
        }
    
      printf ("year = %d\ndays = %d\n", year, days);
      return 0;
    }