{"id":6886,"date":"2025-04-01T00:01:00","date_gmt":"2025-04-01T07:01:00","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=6886"},"modified":"2025-04-08T10:18:01","modified_gmt":"2025-04-08T17:18:01","slug":"a-nutty-non-loop","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=6886","title":{"rendered":"A Nutty Non-Loop"},"content":{"rendered":"<h2>Difficulty: &#9733; &#9733; &#9733; &#9733;<\/h2>\n<p>Loops are fun. They&#8217;re easy to learn. But not everything that repeats in a C program is constructed as a loop.<br \/>\n<!--more--><br \/>\nConsider the following output, my solution to this month&#8217;s Exercise:<\/p>\n<p><code>10<br \/>\n9<br \/>\n8<br \/>\n7<br \/>\n6<br \/>\n5<br \/>\n4<br \/>\n3<br \/>\n2<br \/>\n1<\/code><\/p>\n<p>Yes, this output isn&#8217;t that complicated: Values from 10 to 1 appear &mdash; a countdown. But there&#8217;s a catch.<\/p>\n<p>You must generate this output without using any looping statements, including <em>goto<\/em>. Further, the program must have only one function, <em>main()<\/em>. Use the <em>printf()<\/em> function to output the values. Can you do it?<\/p>\n<p>Oh, and using <em>printf()<\/em> to output values 10 through 1 directly isn&#8217;t a valid solution.<\/p>\n<p><a href=\"https:\/\/c-for-dummies.com\/blog\/?p=6902\">Click here<\/a> to view my insane solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yes, it&#8217;s possible to program a loop without using any looping statements. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=6886\">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-6886","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\/6886","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=6886"}],"version-history":[{"count":4,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6886\/revisions"}],"predecessor-version":[{"id":6940,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6886\/revisions\/6940"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}