
{"id":234,"date":"2018-09-20T15:57:00","date_gmt":"2018-09-20T15:57:00","guid":{"rendered":"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/?page_id=234"},"modified":"2018-09-20T16:10:09","modified_gmt":"2018-09-20T16:10:09","slug":"do-while-loop-glossary-entry","status":"publish","type":"page","link":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/do-while-loop-glossary-entry\/","title":{"rendered":"do-while loop (Glossary Entry)"},"content":{"rendered":"<p>This is a C programming technique for repeating a block of code while some condition is met.<\/p>\n<p>The syntax is as follows:<\/p>\n<pre class=\"theme:xcode lang:c++ decode:true \">do {\r\n\t\/\/ Loop body\r\n} while (&lt;condition to reenter the loop&gt;) \r\n<\/pre>\n<p>Graphically, we can represented this as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-235\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart-393x1024.png\" alt=\"\" width=\"250\" height=\"651\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart-393x1024.png 393w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart-115x300.png 115w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart-383x999.png 383w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart-260x677.png 260w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart-160x417.png 160w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/DoWhileLoop-Flowchart.png 395w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><b>Note<\/b>:<\/p>\n<ul>\n<li>The loop body is always executed at least once (contrast to while loops)<\/li>\n<li>The condition to reenter the loop is evaluated after &#8211; if met, the loop body is repeated, otherwise the loop exits.<span class=\"Apple-converted-space\">\u00a0<\/span><\/li>\n<li>that the condition to enter the loop body is reevaluated each time around the loop.<\/li>\n<\/ul>\n<p><b>break and continue<\/b><\/p>\n<p>As with the <a href=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/mbed-os-2\/courses\/glossary-2\/for-loop-glossary-entry\/\">for-loop<\/a>, it is possible to jump to the end of a loop block with the <b>continue<\/b> statement and break out of the loop early with the <b>break<\/b> statement.<\/p>\n<p>See also: <a href=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/while-loop-glossary-entry\/\">while-loop<\/a>; <a href=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/mbed-os-2\/courses\/glossary-2\/for-loop-glossary-entry\/\">for-loop<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a C programming technique for repeating a block of code while some condition is met. The syntax is as follows: do { \/\/ Loop body } while (&lt;condition to reenter the loop&gt;) Graphically, we can represented this as follows: Note: The loop body is always executed at least once (contrast to while loops)&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/do-while-loop-glossary-entry\/\">Continue reading <span class=\"screen-reader-text\">do-while loop (Glossary Entry)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":153,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-234","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/comments?post=234"}],"version-history":[{"count":4,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/234\/revisions"}],"predecessor-version":[{"id":245,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/234\/revisions\/245"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/153"}],"wp:attachment":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/media?parent=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}