{"id":197,"date":"2020-08-30T15:44:25","date_gmt":"2020-08-30T15:44:25","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/cplusplus\/?p=197"},"modified":"2020-08-30T15:44:25","modified_gmt":"2020-08-30T15:44:25","slug":"c-loops","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/","title":{"rendered":"C++ Loops"},"content":{"rendered":"<p>A loop allows you to execute a statement or groups of statements multiple times based on certain condition. In this lesson, we would consider four types of loops. We would also examine a few loop control statements.<\/p>\n<ol>\n<li><a href=\"#t1\">while Loop<\/a><\/li>\n<li><a href=\"#t2\">for Loop<\/a><\/li>\n<li><a href=\"#t3\">do..while Loop<\/a><\/li>\n<li><a href=\"#t4\">Nested Loop<\/a><\/li>\n<li><a href=\"#t5\">Loop Control Statements<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. while Loop<\/strong><\/h4>\n<p>A while loop is used to execute a statement or group of statements repeatedly so long as a given condition remains true.<\/p>\n<p>The syntax is:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">while(condition) {\r\n   statement(s);\r\n}\r\n<\/pre>\n<p>The flow diagram for the while loop is shown below:<\/p>\n<p><a href=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-198 size-medium aligncenter\" src=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop-250x300.jpg\" alt=\"While Loop\" width=\"250\" height=\"300\" srcset=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop-250x300.jpg 250w, https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop.jpg 556w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>The code below is an example of the while loop.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #333399; font-weight: bold;\">int<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span> () {\r\n   <span style=\"color: #333399; font-weight: bold;\">int<\/span> x <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n\r\n   <span style=\"color: #888888;\">\/\/ while loop<\/span>\r\n   <span style=\"color: #008800; font-weight: bold;\">while<\/span>( x <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span> ) {\r\n\t   <span style=\"color: #888888;\">\/\/Statement<\/span>\r\n      cout <span style=\"color: #333333;\">&lt;&lt;<\/span> <span style=\"background-color: #fff0f0;\">\"x =  \"<\/span> <span style=\"color: #333333;\">&lt;&lt;<\/span> x <span style=\"color: #333333;\">&lt;&lt;<\/span> endl;\r\n      x<span style=\"color: #333333;\">++<\/span>;\r\n   } \r\n   <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n}\r\n<\/pre>\n<p>If you run the above code,\u00a0 you&#8217;ll have the output:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">x =  0\r\nx =  1\r\nx =  2\r\nx =  3\r\nx =  4\r\nx =  5\r\nx =  6\r\nx =  7\r\nx =  8\r\nx =  9\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. for Loop<\/strong><\/h4>\n<p>In the case of a for loop, the\u00a0 statements are executed a specific number of times. So, the number times the loop with iterate is specified. The basic syntax of the for loop is:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">for ( init; condition; increment ) {\r\n   statements;\r\n}\r\n<\/pre>\n<ul>\n<li><strong>init<\/strong> is the loop variable<\/li>\n<li><strong>condition<\/strong> is the conditional statement to the checked each time. Normally\u00a0 the check is if the loop variable have reached certain threshold<\/li>\n<li><strong>increment<\/strong> is by what step to increase the loop variable after each iteration.<\/li>\n<\/ul>\n<p>The flow diagram for the for loop is given below:<\/p>\n<p><a href=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/For-Loop.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-199 aligncenter\" src=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/For-Loop-217x300.jpg\" alt=\"For Loop\" width=\"217\" height=\"300\" srcset=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/For-Loop-217x300.jpg 217w, https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/For-Loop.jpg 633w\" sizes=\"auto, (max-width: 217px) 100vw, 217px\" \/><\/a><\/p>\n<p>The code below illustrates the for loop<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #333399; font-weight: bold;\">int<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span> () {\r\n   <span style=\"color: #888888;\">\/\/ for loop<\/span>\r\n   <span style=\"color: #008800; font-weight: bold;\">for<\/span>( <span style=\"color: #333399; font-weight: bold;\">int<\/span> x <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>; x <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>; x <span style=\"color: #333333;\">=<\/span> x <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span> ) {\r\n      cout <span style=\"color: #333333;\">&lt;&lt;<\/span> <span style=\"background-color: #fff0f0;\">\"value of x is \"<\/span> <span style=\"color: #333333;\">&lt;&lt;<\/span> x <span style=\"color: #333333;\">&lt;&lt;<\/span> endl;\r\n   }\r\n \r\n   <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n}\r\n<\/pre>\n<p>When code execute, x is displayed 10 times as well<\/p>\n<p>Note that in the for loop, the loop variable is declared and initialized inside the for statement.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. do..while Loop<\/strong><\/h4>\n<p>Similar to the while loop, the do&#8230;while loop executes statements a number of times. However, unlike the while loop, the condition is tested at the end of the loop. Therefore, this loop is guaranteed to execute at least, once.<\/p>\n<p>Basic syntax for the do..while loop is:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">do {\r\n   statement;\r\n} \r\nwhile( condition );\r\n<\/pre>\n<p>The flow diagram is shown below:<\/p>\n<p><a href=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/Do-While-Loop.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-200 aligncenter\" src=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/Do-While-Loop-241x300.jpg\" alt=\"Do While Loop\" width=\"241\" height=\"300\" srcset=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/Do-While-Loop-241x300.jpg 241w, https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/Do-While-Loop.jpg 490w\" sizes=\"auto, (max-width: 241px) 100vw, 241px\" \/><\/a><\/p>\n<p>An example of the do&#8230;while loop is given below.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #333399; font-weight: bold;\">int<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span> () {\r\n   <span style=\"color: #888888;\">\/\/ Local variable, x<\/span>\r\n   <span style=\"color: #333399; font-weight: bold;\">int<\/span> x <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n\r\n   <span style=\"color: #888888;\">\/\/ do loop statements<\/span>\r\n   <span style=\"color: #008800; font-weight: bold;\">do<\/span> {\r\n      cout <span style=\"color: #333333;\">&lt;&lt;<\/span> <span style=\"background-color: #fff0f0;\">\"value of x is \"<\/span> <span style=\"color: #333333;\">&lt;&lt;<\/span> x <span style=\"color: #333333;\">&lt;&lt;<\/span> endl;\r\n      x <span style=\"color: #333333;\">=<\/span> x <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>;\r\n   } <span style=\"color: #008800; font-weight: bold;\">while<\/span>( x <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span> );\r\n \r\n   <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n}\r\n<\/pre>\n<p>As before, if you run this code,\u00a0 x is printed 10 times from 0 to 9.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Nested Loop<\/strong><\/h4>\n<p>This is simply a situation when you nest a loop inside another loop. For example, we want to print the running sums of number between 1 and 10. So like this:<\/p>\n<ul>\n<li>1 = <strong>1<\/strong><\/li>\n<li>1 + 2 = <strong>3<\/strong><\/li>\n<li>1 + 2 + 3 = <strong>6<\/strong><\/li>\n<li>1 + 2 + 3 + 4 = <strong>10<\/strong><\/li>\n<li>&#8230;<\/li>\n<\/ul>\n<p>So the output would be 1, 3, 6, 10,&#8230;.<\/p>\n<p>Can you attempt it! Let&#8217;s use two nested for loop.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #333399; font-weight: bold;\">int<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span> () {\r\n\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> sum;\r\n\r\n\t<span style=\"color: #888888;\">\/\/External loop<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">for<\/span>(<span style=\"color: #333399; font-weight: bold;\">int<\/span> i <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>; i <span style=\"color: #333333;\">&lt;=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>; i<span style=\"color: #333333;\">++<\/span>) {\r\n\t\tsum <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n\t\t<span style=\"color: #888888;\">\/\/Nested internal loop<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">for<\/span>(<span style=\"color: #333399; font-weight: bold;\">int<\/span> j <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>; j <span style=\"color: #333333;\">&lt;=<\/span> i; j<span style=\"color: #333333;\">++<\/span>){\r\n\t\t\tsum <span style=\"color: #333333;\">=<\/span> sum <span style=\"color: #333333;\">+<\/span> j;\r\n\t\t}\r\n\t\tcout <span style=\"color: #333333;\">&lt;&lt;<\/span> sum <span style=\"color: #333333;\">&lt;&lt;<\/span> <span style=\"background-color: #fff0f0;\">\", \"<\/span>;\r\n\t}\r\n   <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>;\r\n}\r\n<\/pre>\n<p>The output of the code would be:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \r\n<\/pre>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. Loop Control Statements<\/strong><\/h4>\n<p>Discussion\u00a0 on loop is not complete without learning about loop control statements.<\/p>\n<p>Loop control statements allow you to alter the normal loop execution sequence. For instance, you saw from<a href=\"https:\/\/kindsonthegenius.com\/cplusplus\/c-conditional-statements\/#t4\" target=\"_blank\" rel=\"noopener noreferrer\"> switch statement<\/a> that we used break statement to exit from the switch statements. Lets\u00a0 look at three loop control statements.<\/p>\n<p><strong>break statement<\/strong> &#8211; this statement is used to completely terminate the loop and exit to the statements following the loop<\/p>\n<p><strong>continue statement<\/strong> &#8211; this statement is used to terminate the current iteration of the loop<\/p>\n<p><strong>goto statement<\/strong> &#8211; this statement is used to transfer control to another part of the program with a label. Goto statements are not recommended for most scenarios.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A loop allows you to execute a statement or groups of statements multiple times based on certain condition. In this lesson, we would consider four &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-197","post","type-post","status-publish","format-standard","hentry","category-c-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C++ Loops - C++ Tutorials<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++ Loops - C++ Tutorials\" \/>\n<meta property=\"og:description\" content=\"A loop allows you to execute a statement or groups of statements multiple times based on certain condition. In this lesson, we would consider four &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/\" \/>\n<meta property=\"og:site_name\" content=\"C++ Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-30T15:44:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"556\" \/>\n\t<meta property=\"og:image:height\" content=\"666\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/#\\\/schema\\\/person\\\/59a11a9f72bb132f56f91ab9f8a58a0e\"},\"headline\":\"C++ Loops\",\"datePublished\":\"2020-08-30T15:44:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/\"},\"wordCount\":481,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/While-Loop-250x300.jpg\",\"articleSection\":[\"C++ Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/\",\"name\":\"C++ Loops - C++ Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/While-Loop-250x300.jpg\",\"datePublished\":\"2020-08-30T15:44:25+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/#\\\/schema\\\/person\\\/59a11a9f72bb132f56f91ab9f8a58a0e\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#primaryimage\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/While-Loop.jpg\",\"contentUrl\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/While-Loop.jpg\",\"width\":556,\"height\":666,\"caption\":\"While Loop\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/c-loops\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ Loops\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/#website\",\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/\",\"name\":\"C++ Tutorials\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/#\\\/schema\\\/person\\\/59a11a9f72bb132f56f91ab9f8a58a0e\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/kindsonthegenius.com\\\/cplusplus\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++ Loops - C++ Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/","og_locale":"en_US","og_type":"article","og_title":"C++ Loops - C++ Tutorials","og_description":"A loop allows you to execute a statement or groups of statements multiple times based on certain condition. In this lesson, we would consider four &hellip;","og_url":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/","og_site_name":"C++ Tutorials","article_published_time":"2020-08-30T15:44:25+00:00","og_image":[{"width":556,"height":666,"url":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#article","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/#\/schema\/person\/59a11a9f72bb132f56f91ab9f8a58a0e"},"headline":"C++ Loops","datePublished":"2020-08-30T15:44:25+00:00","mainEntityOfPage":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/"},"wordCount":481,"commentCount":0,"image":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop-250x300.jpg","articleSection":["C++ Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/","url":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/","name":"C++ Loops - C++ Tutorials","isPartOf":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#primaryimage"},"image":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop-250x300.jpg","datePublished":"2020-08-30T15:44:25+00:00","author":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/#\/schema\/person\/59a11a9f72bb132f56f91ab9f8a58a0e"},"breadcrumb":{"@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#primaryimage","url":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop.jpg","contentUrl":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-content\/uploads\/2020\/08\/While-Loop.jpg","width":556,"height":666,"caption":"While Loop"},{"@type":"BreadcrumbList","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/c-loops\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kindsonthegenius.com\/cplusplus\/"},{"@type":"ListItem","position":2,"name":"C++ Loops"}]},{"@type":"WebSite","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/#website","url":"https:\/\/kindsonthegenius.com\/cplusplus\/","name":"C++ Tutorials","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kindsonthegenius.com\/cplusplus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kindsonthegenius.com\/cplusplus\/#\/schema\/person\/59a11a9f72bb132f56f91ab9f8a58a0e","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/kindsonthegenius.com\/cplusplus\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/posts\/197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/posts\/197\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/cplusplus\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}