while and do while in C++|| C++ Complete Course || Beginners to Advance| Urdu/Hindi | BJM Tech

Published: 25 November 2022
on channel: BJM Technologies
33
2

C++ Loops
Loops can execute a block of code as long as a specified condition is reached.

Loops are handy because they save time, reduce errors, and they make code more readable.

C++ While Loop
The while loop loops through a block of code as long as a specified condition is true:

Syntax
while (condition) {
// code block to be executed
}
In the example below, the code in the loop will run, over and over again, as long as a variable (i) is less than 5:

Example
int i = 0;
while (i ( 5) {
cout (( i (( "\n";
i++;
}
Note: Do not forget to increase the variable used in the condition, otherwise the loop will never end!


Watch video while and do while in C++|| C++ Complete Course || Beginners to Advance| Urdu/Hindi | BJM Tech online without registration, duration hours minute second in high quality. This video was added by user BJM Technologies 25 November 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3 once and liked it people.