Day of week

From Programming In C

Exercise 4.1

Note: this is an example of an actual assessment

Write a program that calculates the DAY of the week (e.g. Monday) for any date between 1st January 2011 and 31st December 2011.

Hint: think about how many days have passed in the year and integer division.

Your program will input (via scanf) a date and a month in any format you choose and will return (via printf) the day of the week.

So, for example running your code might result in the following dialogue (in bold is what you would enter at the keyboard):

 Please enter date in month: 25
 Please enter month (1=January, 12=December): 12
 25th Dec 2011 is a Sunday

You need to know that 1st January 2011 was a Saturday

Note: you should print out the date as an ordinal number, e.g. 1st, 2nd, 3rd, etc.


Next exercise

Return to the course summary

phy225: Course Details

general


compilers


2011-12 assessments


past exam papers

  • 2008-9 (http://physics-database.group.shef.ac.uk/exampapers/2008-09/PHY225%20LT.pdf)
  • 2009-10 (http://physics-database.group.shef.ac.uk/exampapers/2009-10/PHY225%20Exam%20Sem%201%202009-10.pdf)
  • 2010-11 (http://physics-database.group.shef.ac.uk/exampapers/2010-11/PHY225_10_11.pdf)