{"id":3382,"date":"2018-12-01T00:01:35","date_gmt":"2018-12-01T08:01:35","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=3382"},"modified":"2018-12-08T08:54:42","modified_gmt":"2018-12-08T16:54:42","slug":"the-whole-month-from-a-single-day","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=3382","title":{"rendered":"The Whole Month from a Single Day"},"content":{"rendered":"<p>Months have a pattern: All months feature weeks of seven days. The month can start on any day of the week. And months have a varying number of total days, 28, 29, 30, or 31. Given this data, you can display the days and weeks of any month when given only a specific date and the day of the week upon which it falls.<br \/>\n<!--more--><br \/>\nFor example, this month is December. It has 31 days, spread across several weeks of 7 days each. The 25th of the month, Christmas, falls on a Tuesday this year. Given this data, you can accurately reconstruct the entire month:<\/p>\n<pre><code>Sun Mon Tue Wed Thu Fri Sat\r\n                          1 \r\n  2   3   4   5   6   7   8 \r\n  9  10  11  12  13  14  15 \r\n 16  17  18  19  20  21  22 \r\n 23  24  25  26  27  28  29 \r\n 30  31<\/code><\/pre>\n<p>Your task for this month&#8217;s Exercise is to write a function, <em>month()<\/em>. The function accepts two arguments, <code>day<\/code> and <code>weekday<\/code>: <code>day<\/code> is the day of the month, such as 25 for the 25th, and <code>weekday<\/code> is an integer value 0 through 6 representing Sunday through Saturday.<\/p>\n<p>Here is a skeleton to help get you started, along with a few arguments you need to process to complete the Exercise:<\/p>\n<pre class=\"screen\">\r\n#include &lt;stdio.h&gt;\r\n\r\nenum { SUN, MON, TUE, WED, THU, FRI, SAT };\r\n\r\nvoid month(int day, int weekday)\r\n{\r\n\r\n}\r\n\r\nint main()\r\n{\r\n    month(15,WED);\r\n    month(9,MON);\r\n    month(23,SUN);\r\n\r\n    return(0);\r\n}<\/pre>\n<p>The <em>main()<\/em> function contains three statements that the <em>month()<\/em> function must process and output in the calendar-like format shown earlier. For simplicity&#8217;s sake, assume that each month has only 30 days. <\/p>\n<p>Please try this Exercise on your own before you check out <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3394\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Given a day of the week and date of the month, reconstruct the entire month and output it one week. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3382\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3382","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3382"}],"version-history":[{"count":4,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3382\/revisions"}],"predecessor-version":[{"id":3418,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3382\/revisions\/3418"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}