Question: Can someone help me write a program for this in c? From Project Euler, Counting Sundays: You are given the following information, but you may
From Project Euler, Counting Sundays: You are given the following information, but you may prefer to do some research for yourself 1 Jan 1900 was a Monday. Thirty days has September, April, June and November A1l the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine And on leap years, twenty-nine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400 How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? And no 1/1/1901 is not a typo. Name your source code sundays.c. Capture the output in a script file named sundays.script Some hints: 1. You can use the cal command to display the calendar any year, e.g. S cal 1900 2. There is a reason they say 1 Jan 1900 falls on a Monday 3. You can determine if a year is a leap year by using the following: if (year % 4 -0 && year % 100 ! 0) | | year % 400- 0) /leap year / else /*not a leap year */ 4. As a way to get started: manually figure out, using cal, how many Sundays fell on the first of the month between 1901 and 1905 and write a program to solve that. After that program works correctly extend it to the year 2000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
