logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/sternflCode/h3/leap.c

/*

leap.c - find whether the given year is a leap year or a common year

Under our current calendar, the Gregorian Calendar, the rule for leap years is 
as follows:

1. A year may be a leap year if it is evenly divisible by 4.
2. Years that are divisible by 100 (century years such as 1900 or 2000) cannot 
   be leap years unless they are also divisible by 400. For this reason, the 
   years 1700, 1800, and 1900 were not leap years, but the years 1600 and 2000 
   were.

Years that are not leap years are called "common" years.

So under these rules
2021 - common
2020 - leap (divisible by 4)
2000 - leap (divisible by 4, 100, and 400)
1900 - common (divisible by 4 and 100 but not 400)

*/

#include <stdio.h>

int main(){

	int year; //declaring variable for the year

	//get the year from the user
	printf("Enter the year> "); 
	scanf("%d", &year);

	//now set up the if/else-if statements here

	/*
	 Hint: the Wikipedia Article on Leap Year, in the Gregorian Calendar section, 
	       has pseudocode on determining  whether a year is leap or common.
	*/
	return 0;

}