{"id":2688,"date":"2022-06-19T21:10:42","date_gmt":"2022-06-20T01:10:42","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/?p=2688"},"modified":"2022-06-19T21:10:42","modified_gmt":"2022-06-20T01:10:42","slug":"the-difference-between-for-and-while-loops","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/2022\/06\/19\/the-difference-between-for-and-while-loops\/","title":{"rendered":"The Difference Between For and While Loops"},"content":{"rendered":"<p>What is a for loop? It is a loop used when the number of iterations are known. A while loop is used when the number of iterations are unknown. This is the main difference between the two loops. Another big difference is that with for loops, initialization happens inside or outside of the loop but a while loop initialization only happens in the loop. And finally, with for loops, if the condition is not stated in the for loop, the loop will iterate an infinite number of times. In a while loop, a complication error will result if the condition is not stated in the loop.\u00a0<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 18pt\"><strong>For Loop\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 While Loop<\/strong><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/www.tutorialspoint.com\/assets\/questions\/media\/50328\/code_block.jpg\" width=\"226\" height=\"317\" \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/www.tutorialspoint.com\/assets\/questions\/media\/50328\/condition.jpg\" width=\"193\" height=\"296\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is a for loop? It is a loop used when the number of iterations are known. A while loop is used when the number of iterations are unknown. This is the main difference between the two loops. Another big difference is that with for loops, initialization happens inside or outside of the loop but [&hellip;]<\/p>\n","protected":false},"author":28313,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[663943],"tags":[],"class_list":{"0":"post-2688","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-instructor","7":"entry"},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/posts\/2688","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/users\/28313"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/comments?post=2688"}],"version-history":[{"count":5,"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/posts\/2688\/revisions"}],"predecessor-version":[{"id":2702,"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/posts\/2688\/revisions\/2702"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/media?parent=2688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/categories?post=2688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec712summer2022\/wp-json\/wp\/v2\/tags?post=2688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}