{"id":601,"date":"2025-07-21T09:41:53","date_gmt":"2025-07-21T09:41:53","guid":{"rendered":"https:\/\/tipcontrol.com\/?page_id=601"},"modified":"2025-07-21T09:41:54","modified_gmt":"2025-07-21T09:41:54","slug":"while-statement","status":"publish","type":"page","link":"https:\/\/tipcontrol.com\/?page_id=601","title":{"rendered":"while statement"},"content":{"rendered":"\n<p>The <code>while<\/code> loop is a control structure in Tipcontrol and similar to languages like C++,it is used to repeat a block of code as long as a specified condition evaluates to true. It is particularly useful when the number of iterations is not known beforehand and should be determined dynamically at runtime.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Structure of a&nbsp;<code>while<\/code>&nbsp;Loop<\/h4>\n\n\n\n<p><strong>Components<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Condition<\/strong>: An expression evaluated before each iteration of the loop. If the condition evaluates to\u00a0<code>true<\/code>\u00a0(non-zero), the code block inside the loop is executed. If it evaluates to\u00a0<code>false<\/code>\u00a0(zero), the loop terminates.<\/li>\n\n\n\n<li><strong>Code Block<\/strong>: The block of code that executes during each iteration while the condition is true. This block is enclosed in curly braces\u00a0<code>{}<\/code>.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Simple Example<\/h4>\n\n\n\n<p>&nbsp; &nbsp; counter = 1; \/\/ Initialization<\/p>\n\n\n\n<p>&nbsp; &nbsp; \/\/ Loop while counter is less than or equal to 5<\/p>\n\n\n\n<p>&nbsp; &nbsp; while (counter &lt;= 5) {<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; lib.log(&#8220;Count: \u201c+ counter);<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; counter+=1; \/\/ Update the counter<\/p>\n\n\n\n<p>&nbsp; &nbsp; };<\/p>\n\n\n\n<p><strong>Explanation<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Initialization<\/strong>:\u00a0<code>counter = 1;<\/code>\u00a0initializes a counter variable.<\/li>\n\n\n\n<li><strong>Condition<\/strong>:\u00a0<code>counter &lt;= 5<\/code>\u00a0checks if the counter is less than or equal to 5.<\/li>\n\n\n\n<li><strong>Code Block<\/strong>: The statement\u00a0<code>lib.log(\"Count: \u201c+ counter);<\/code>\u00a0is executed as long as the condition is true.<\/li>\n\n\n\n<li><strong>Update<\/strong>:\u00a0<code>counter+=1<\/code>\u00a0increments the counter at the end of each iteration to eventually make the condition false and terminate the loop.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The while loop is a control structure in Tipcontrol and similar to languages like C++,it is used to repeat a block of code as long as a specified condition evaluates to true. It is particularly useful when the number of iterations is not known beforehand and should be determined dynamically at runtime. Structure of a&nbsp;while&nbsp;Loop [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-601","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=601"}],"version-history":[{"count":1,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/601\/revisions"}],"predecessor-version":[{"id":602,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/601\/revisions\/602"}],"wp:attachment":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}