Professional Documents
Culture Documents
Lab
Lecture 4
Iteration cause statements to be executed zero or more times, subject to some loop-
termination criteria.
When these statements are compound statements, they are executed in order, except when
either the break statement or the continue statement is encountered.
Syntax
while ( expression )
{
Statement;
}
A while loop can also terminate when break, goto or return within the statement body is
executed.
Use continue to terminate the current iteration without exiting the while loop.
Continue passes control to the next iteration of the while loop.
int main () {
// Local variable declaration:
int a = 1;
// while loop execution
while( a <= 20 ) {
cout << "value of a: " << a << endl;
a++;
}
return 0;
}
Write a program to print the numbers from 10 in descending order.(Using while loop)
Write a program take the limit of the series from user and using While loop find the sum of
the series.
Write a program in C++ language to find the factorial of a number. (using while loop)