While Loop in C++ Programming Language
While Loop in C++ Programming Language We have discussed about the entry-controlled loop or pre-tested loop previously in our blog posts. These statements or loops are used to repeat a piece of code for a specific number of times as per our program requirement. We have studied about the for loop already. Today in this blog post we are going to study about the while loop in C++ programming language. And we will look at how this while loop actually works and how we can stop it by making some condition false so that the loop might not run infinitely. We use while loop in C++ program when the number of iterations is not known in advance and depends on the condition. When we know exactly, that how many times a loop should run then we use the for loop instead of while loop. Basic syntax and working of while loop in C++ programming language Syntax of while loop int i = 1; while (condition) { // code of block to be executed here. ...