{"id":1653,"date":"2015-12-01T00:01:08","date_gmt":"2015-12-01T08:01:08","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=1653"},"modified":"2015-12-10T08:22:39","modified_gmt":"2015-12-10T16:22:39","slug":"merry-cumulative-song-exercise","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=1653","title":{"rendered":"Merry Cumulative Song Exercise"},"content":{"rendered":"<p>In my C programming books, I often use the directions on a shampoo bottle as an example of basic programming:<\/p>\n<p>1. Lather.<br \/>\n2. Rinse.<br \/>\n3. Repeat.<\/p>\n<p>Another real-life example of programming techniques happens in music. Specifically, cumulative songs are representative of loops. This type of song includes <em>99 Bottles of Beer<\/em> and the holiday favorite, <em>The Twelve Days of Christmas<\/em>.<br \/>\n<!--more--><br \/>\nA cumulative song has repetitive lyrics. They&#8217;re fun to sing, but do get tiresome after a while. I believe I last sang the full rendition of <em>The Twelve Days of Christmas<\/em> when I was 8-years-old. (That&#8217;s not counting singing along with Alan Sherman&#8217;s <a href=\"https:\/\/www.youtube.com\/watch?v=ZcJu2OFFdP8\" target=\"_blank\">famous parody<\/a>. And even he doesn&#8217;t repeat every lyric.)<\/p>\n<p>This month&#8217;s Exercise is to write code that spits out the lyrics for <em>The Twelve Days of Christmas<\/em>. And I&#8217;d like you to do more than simply write several dozen <em>printf()<\/em> statements: The code must include a loop that outputs the lyrics.<\/p>\n<p>As a refresher, <a href=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/11\/lyrics.txt\">click here<\/a> to view the lyrics, as well as see the output of my solution to the Exercise.<\/p>\n<p>Please try this exercise on your own before you peek at <a href=\"http:\/\/c-for-dummies.com\/blog\/?p=1674\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Coding the lyrics for a popular Christmas song with repetitive lyrics. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=1653\">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-1653","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\/1653","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=1653"}],"version-history":[{"count":4,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1653\/revisions"}],"predecessor-version":[{"id":1688,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1653\/revisions\/1688"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}