Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Leap year. Write a function bool leap_year(int year); that tests whether a year

ID: 3614139 • Letter: L

Question

Leap year. Write a function

bool leap_year(int year);

that tests whether a year is a leap year: that is, a year with 366days. Leap years are necessary to keep the calendar synchronizedwith the sun because the earth revolves around the sun once every365.25 days. Actually, the figure is not entirely precise, and forall dates after 1580 the Gregorian correction applies. Usuallyyears that are divisible by 4 but is not a century year are leapyears, century years that are not divisible by 400 are not leapyears, century years that are divisible by 400 are leap years.

Write a program to test your leap_year() function with at least oneinput year from each of the following four year types.

1. Non-century non-leap years (e.g., 1995, 1997)
2. Non-century leap years (e.g, 1980, 1984)
3. Century non-leap years (e.g., 1700, 1800)
4. Century leap years (e.g., 2000, 2400)

Algorithm

"

If year%400 == 0

       leapyear = True

elif year%100 == 0

       leapyear = False

elif year%4 == 0

       leapyear = True

else

       leapyear = False

"

where % means the remainder of the division (i.e 7%3 =1)

Explanation / Answer

//I found it here, hope this will helpyou. http://supermanhelp.com/view_ques.aspx?data=633878964586031220.txt just replace int isLeapYear(int yr)
{
   if( ((yr %4==0) && (yr%100 !=0 )) || (yr%400==0))
        {
      printf("This year (%d) is leapyear ",yr);
      return 1;
        }
      else
        {
      printf("This year (%d) is not leapyear ",yr);
      return 0;
        }
}
with bool and return with true orfalse. just replace int isLeapYear(int yr)
{
   if( ((yr %4==0) && (yr%100 !=0 )) || (yr%400==0))
        {
      printf("This year (%d) is leapyear ",yr);
      return 1;
        }
      else
        {
      printf("This year (%d) is not leapyear ",yr);
      return 0;
        }
}
with bool and return with true orfalse.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote