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

Repeat SPIDER 2 Q1, but write a function that accepts a year as an input argumen

ID: 3860628 • Letter: R

Question

Repeat SPIDER 2 Q1, but write a function that accepts a year as an input argument and determines whether that year is a leap year. The output should be the variable extra_day, which should be 1 if the year is a leap year and 0 otherwise. Spider two Q1 1. Write code to determine whether a year is a leap year. Use the mod function. The rules for determining leap years in the Gregorian calendar are as follows: 1. All years evenly divisible by 400 are leap years. 2. Years evenly divisible by 100, but not by 400, are not leap years. 3. Years divisible by 4, but not by 100, are leap years. 4. All other years are not leap years. For example, the years 1800, 1900, 2100, 2300 and 2500 are not leap years, but 2400 is a leap year.

Explanation / Answer

#include <stdio.h>

int leap_year(int year)

{

int extra_day;

extra_day=year%4;

if(extra_day==0)

return 1;

else

return 0;

}

int main(void) {

// your code goes here

int year,x;

printf("Enter the number of years");

scanf("%d",&year);

x=leap_year(year);

printf(" Answer:%d",x);

return 0;

}