While Loop
The while loop is used to repeat statements while a particular condition is true.
Syntax for while loop:
Statement x
While (condition):
Statement Block
Statement Y
Construct:
Example: Program to print first 10 number using a while loop:
Program to print first 10 numbers horizontally :
Example 2: Write a program to calculate the sum and average of first 10 numbers.
Supplementary Problems:
1. Write a program to display even numbers between 100 and 200.
2. Write a program to print 20 horizontal asterisks(*)
3. Write a program to calculate the sum of numbers from m to n.
4. Write a program to print a countdown from a number to zero.
5. Write a program to print the reverse of a number.