{"id":14061,"date":"2020-03-30T18:08:33","date_gmt":"2020-03-31T01:08:33","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=14061"},"modified":"2023-12-01T02:35:54","modified_gmt":"2023-12-01T10:35:54","slug":"c-plus-plus-do-while-loop","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/","title":{"rendered":"Do while Loop C++"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">How to Use \u201cwhile\u201d Loops in C++<\/h2>\n\n\n\n<p>In programming, you can automate repetitive tasks with loops. Loops are an important part of programming because they allow developers to reduce code repetition. This reduction helps make code more efficient and easier to read.<\/p>\n\n\n\n<p><code>while<\/code> and <code>do \u2026 while<\/code> loops are two of the three main types of loops in C++. while and do \u2026 while loops execute a block of code as long as a specific condition evaluates to true; otherwise, the loop will stop executing and the program will move past the while block.<\/p>\n\n\n\n<p>This tutorial will discuss, with examples, the basics of loops in C++ and how to use while and do \u2026 while loops in your code. By the end of reading this guide, you\u2019ll be an expert at using while and do \u2026 while loops in C++.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C++ Loops<\/h2>\n\n\n\n<p>Loops execute a specific block of code based on whether a condition is met. In C++, there are three types of loops:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>for loops<\/li>\n\n\n\n<li>while loops<\/li>\n\n\n\n<li>do \u2026 while loops<\/li>\n<\/ul>\n\n\n\n<p><code>for<\/code> loops execute a block of code until a test expression evaluates to false. For instance, a for loop may print out every number in the range of 1 and 10 or calculate the power of every number between 19 and 27.<\/p>\n\n\n\n<p>while and do \u2026 while loops, on the other hand, allow you to execute a block of code while a condition evaluates to true. This means you don\u2019t need to know how many times the loop should run before you create the loop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C++ while Loop<\/h2>\n\n\n\n<p>The C++ while loop executes as long as a specific statement evaluates to true. The syntax for a while loop is almost exactly the same as that of an <code>if<\/code> statement; the only difference is that the <code>while<\/code> keyword is used instead of <code>if<\/code>.<\/p>\n\n\n\n<p>Here\u2019s the syntax for a while loop in C++:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>while (expression) {\n\t\/\/ Run code while condition is true\n}<\/pre><\/div>\n\n\n\n<p>Here is how a while loop works in C++:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The program evaluates the stated expression in the while loop.<\/li>\n\n\n\n<li>If the expression is equal to true, the program executes the code in the while loop body.<\/li>\n\n\n\n<li>The program then evaluates the expression again.\n<ol class=\"wp-block-list\">\n<li>If the expression is still equal to true, the program executes the code in the while loop body again.<\/li>\n\n\n\n<li>If the expression evaluates to false, the program terminates the while loop.<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>This process continues until the expression evaluates to false and the program terminates the while loop.<\/li>\n<\/ol>\n\n\n\n<p>Let\u2019s walk through an example to demonstrate how the C++ while loop works in a program.<\/p>\n\n\n\n<p>Suppose we are operating a local superstore and are looking to hire 10 seasonal workers to help us with the Christmas rush.<\/p>\n\n\n\n<p>Every time our loop executes, we want to add a new employee to a counter that keeps track of how many seasonal workers we have on staff. Once we have 10 seasonal workers, the program should stop running the while loop.<\/p>\n\n\n\n<p>Here\u2019s the code we can use to accomplish this task:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>#include &lt;iostream&gt;\ninclude namespace std;\nint main() {\n\tint workersToHire = 10, workersHired = 0;\n\twhile (workersHired &lt; workersToHire) {\n\t\t++workersHired;\n\t\tint leftToHire = workersToHire - workersHired;\n\t\tcout &lt;&lt; \"There are \" &lt;&lt; workersToHire &lt;&lt; \" workers left to hire.\" &lt;&lt; std:endl;\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>There are 9 workers left to hire.\nThere are 8 workers left to hire.\nThere are 7 workers left to hire.\nThere are 6 workers left to hire.\nThere are 5 workers left to hire.\nThere are 4 workers left to hire.\nThere are 3 workers left to hire.\nThere are 2 workers left to hire.\nThere are 1 workers left to hire.\nThere are 0 workers left to hire.<\/pre><\/div>\n\n\n\n<p>Let\u2019s walk through our code. First, we declare a variable called workersToHire. This variable stores how many workers we want to hire. We also declare a variable called workersHired. This variable keeps track of how many seasonal workers we have already hired.<\/p>\n\n\n\n<p>On the next line, we initialize a while loop that runs while the value of workersToHire is greater than workersHired. So, the loop will run until workersHired is equal to workersToHire.<\/p>\n\n\n\n<p>In our while loop, we use the ++ increment operator to add 1 to the value of workersHired. We then declare a variable called leftToHire that calculates how many employees we can hire until we reach our capacity. Finally, we print out the message There are X workers left to hire. to the console, where X is equal to the value stored in leftToHire.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C++ do \u2026 while Loop<\/h2>\n\n\n\n<p>So far, we have discussed how the while loop is used. while loops execute a block of statements as long as a condition is checked and evaluates to true.<\/p>\n\n\n\n<p>do \u2026 while loops are a form of the while loop but with one difference: do \u2026 while loops execute once, after which the program evaluates a specified condition. Here\u2019s the syntax for a C++ do while loop:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>do {\n\t\/\/ Run code\n} while (expression);<\/pre><\/div>\n\n\n\n<p>Above you can see that the do statement is first. The while statement, which accepts a test expression, follows the do statement. Here is how a do \u2026 while loop works:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The program executes the code within the do block.<\/li>\n\n\n\n<li>The program evaluates the expression within the while statement.\n<ol class=\"wp-block-list\">\n<li>If the specified expression evaluates to true, the loop executes again.<\/li>\n\n\n\n<li>If the specified expression evaluates to false, the program terminates the loop.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<p>Let\u2019s walk through an example to explain in more depth how the do \u2026 while loop condition works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example of do \u2026 while<\/h2>\n\n\n\n<p>Suppose we are building a guessing game that allows a user to guess a number between 1 and 10. If the user guesses the right number, the program should print a message to the console congratulating them; otherwise, the user should be allowed to guess again.<\/p>\n\n\n\n<p>If the user does not guess the right number in three guesses, the program should print a message to the console informing the user that they lost the game.&nbsp;<\/p>\n\n\n\n<p>Here\u2019s the code we can use to create our guessing game:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>#include &lt;iostream&gt;\ninclude namespace std;\nint main() {\n\tint numberToGuess = 7, guessesLeft = 3, guessed = 0;\n\tbool correct = false;\n\tdo {\n\t\tcout&lt;&lt;\"Enter a number between 1 and 10: \";\n\t\tcin&gt;&gt;guessed;\n\t\tguessesLeft = guessesLeft - 1;\n\t\tif (guessed == numberToGuess) {\n\t\t\tcorrect = true;\n\t\t\tbreak;\n\t\t}\n\t} while (guessesLeft &gt; 0);\n\tif (correct == true) {\n\t\tcout&lt;&lt;\"Congrats! You guessed the right number.\";\n\t} else {\n\t\tcout&lt;&lt;\"You lost! You didn't guess the right number in three guesses.\";\n\t}\n}<\/pre><\/div>\n\n\n\n<p>This is the result of our code after guessing three numbers incorrectly:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter a number between 1 and 10: 1\nEnter a number between 1 and 10: 9\nEnter a number between 1 and 10: 2\nYou lost! You didn't guess the right number in three guesses.<\/pre><\/div>\n\n\n\n<p>When we guess the right number, the program returns the following response: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Enter a number between 1 and 10: 7\nCongrats! You guessed the right number.<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. First we declare four variables that we need to build our guessing game:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>numberToGuess is the number the player needs to guess. In this case, numberToGuess is equal to 7.<\/li>\n\n\n\n<li>guessesLeft is the number of guesses the player has remaining. This is set to 3 in our code.<\/li>\n\n\n\n<li>guessed is the number the user has guessed. By default, we set this to 0.<\/li>\n\n\n\n<li>correct keeps track of whether the user has guessed the right number. This is set to false by default and will only change to true if the user guesses the right number;<\/li>\n<\/ol>\n\n\n\n<p>Then we use a do \u2026 while loop to create our guessing game mechanism. The program executes the contents of the do statement once, before it evaluates any condition. Our do statement asks a user to enter a number, assigns the number the user guesses to the variable guessed, and reduces the number of guesses a user has left by 1.<\/p>\n\n\n\n<p>If the number the user enters is equal to numberToGuess, the variable correct is set to true and a break statement stops the do \u2026 while loop from executing again.<\/p>\n\n\n\n<p>Then, our program evaluates whether guessesLeft is less than 0 in the while statement. If the user has more than 0 guesses left, the program will execute the contents of the do statement again; otherwise, the program will stop executing the do loop and will continue running the main program.<\/p>\n\n\n\n<p>We also specified an if statement that checks whether the user guessed the correct number. If the user guessed the correct number, the program prints the message Congrats! You guessed the right number. to the console; otherwise, the program prints the message You lost! You didn\u2019t guess the right number in three guesses. to the console, after the user has had three unsuccessful guesses.<\/p>\n\n\n\n<p>Using a do \u2026 while loop is effective in this example because we want to give the user a chance to guess once before we check how many guesses they have left. The do \u2026 while loop allows our user to guess once, after which the loop checks whether they have any more guesses left.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In C++, while loops execute as long as a specific condition evaluates to true. do \u2026 while loops execute once first, after which the program determines whether a specific condition evaluates to true. If the condition evaluates to true, the loop runs again; otherwise, the do \u2026 while loop terminates.<\/p>\n\n\n\n<p>This tutorial explored, with examples, the basics of loops in C++ and how you can use while and do \u2026 while loops in your code. Now you\u2019re equipped with the knowledge you need to start using while and do \u2026 while loops like a C++ pro!<\/p>\n","protected":false},"excerpt":{"rendered":"How to Use \u201cwhile\u201d Loops in C++ In programming, you can automate repetitive tasks with loops. Loops are an important part of programming because they allow developers to reduce code repetition. This reduction helps make code more efficient and easier to read. while and do \u2026 while loops are two of the three main types&hellip;","protected":false},"author":240,"featured_media":14062,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17291],"tags":[],"class_list":{"0":"post-14061","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-c-plus-plus"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"C++","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Do while Loop C++ | Career Karma<\/title>\n<meta name=\"description\" content=\"In C++, \u201cwhile\u201d and \u201cdo while\u201d loops are used to execute a block of code based on whether a condition is met. On Career Karma, learn how to use these loops.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Do while Loop C++\" \/>\n<meta property=\"og:description\" content=\"In C++, \u201cwhile\u201d and \u201cdo while\u201d loops are used to execute a block of code based on whether a condition is met. On Career Karma, learn how to use these loops.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-31T01:08:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:35:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/blur-bottle-bright-building-273238-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Do while Loop C++\",\"datePublished\":\"2020-03-31T01:08:33+00:00\",\"dateModified\":\"2023-12-01T10:35:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/\"},\"wordCount\":1340,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/blur-bottle-bright-building-273238-1.jpg\",\"articleSection\":[\"C++ Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/\",\"name\":\"Do while Loop C++ | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/blur-bottle-bright-building-273238-1.jpg\",\"datePublished\":\"2020-03-31T01:08:33+00:00\",\"dateModified\":\"2023-12-01T10:35:54+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"In C++, \u201cwhile\u201d and \u201cdo while\u201d loops are used to execute a block of code based on whether a condition is met. On Career Karma, learn how to use these loops.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/blur-bottle-bright-building-273238-1.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/blur-bottle-bright-building-273238-1.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus-do-while-loop\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ Programming\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/c-plus-plus\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Do while Loop C++\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Do while Loop C++ | Career Karma","description":"In C++, \u201cwhile\u201d and \u201cdo while\u201d loops are used to execute a block of code based on whether a condition is met. On Career Karma, learn how to use these loops.","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:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/","og_locale":"en_US","og_type":"article","og_title":"Do while Loop C++","og_description":"In C++, \u201cwhile\u201d and \u201cdo while\u201d loops are used to execute a block of code based on whether a condition is met. On Career Karma, learn how to use these loops.","og_url":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-31T01:08:33+00:00","article_modified_time":"2023-12-01T10:35:54+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/blur-bottle-bright-building-273238-1.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Do while Loop C++","datePublished":"2020-03-31T01:08:33+00:00","dateModified":"2023-12-01T10:35:54+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/"},"wordCount":1340,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/blur-bottle-bright-building-273238-1.jpg","articleSection":["C++ Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/","url":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/","name":"Do while Loop C++ | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/blur-bottle-bright-building-273238-1.jpg","datePublished":"2020-03-31T01:08:33+00:00","dateModified":"2023-12-01T10:35:54+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"In C++, \u201cwhile\u201d and \u201cdo while\u201d loops are used to execute a block of code based on whether a condition is met. On Career Karma, learn how to use these loops.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/blur-bottle-bright-building-273238-1.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/blur-bottle-bright-building-273238-1.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/c-plus-plus-do-while-loop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"C++ Programming","item":"https:\/\/careerkarma.com\/blog\/c-plus-plus\/"},{"@type":"ListItem","position":3,"name":"Do while Loop C++"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/14061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=14061"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/14061\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/14062"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=14061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=14061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=14061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}