What is while Loop?
As long as the (while
) statement’s condition evaluates to true, the (while
) assertion cycles around a block of code. They’re used to run a section of code repeatedly until the set condition is met. The while loop keeps repeating an action until an associated condition returns false.
Syntex:-
while (condition is true) {
code to be executed;
}
Example1:-
Output:-
Example2:-
Output:-