C++ Do While Loop
Before testing the condition the body of the loop is necessary to execute in those situations, it can be handled by using do-while loop method in C++ program. do statement which evaluates the body of the loop first and the condition will be checked by using the while statement at the end. In do while loop at least one time the body of the loop will be executed, even condition is true or false.
Syntax:-
do{ statement(s);//code to be executed }while(condition);
Example:-
#include <iostream> using namespace std; int main(){ int a=1; do{ cout << a << endl; a++; }while(a<=5); return 0; }
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.