0% found this document useful (0 votes)
5 views2 pages

Understanding While Loops in Programming

The document explains the while loop, which is used to repeat statements as long as a specified condition is true, and provides its syntax. It includes examples of programs that utilize the while loop, such as printing the first 10 numbers and calculating their sum and average. Additionally, it lists supplementary problems for practice, including displaying even numbers and printing a countdown.

Uploaded by

dishuu2001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Understanding While Loops in Programming

The document explains the while loop, which is used to repeat statements as long as a specified condition is true, and provides its syntax. It includes examples of programs that utilize the while loop, such as printing the first 10 numbers and calculating their sum and average. Additionally, it lists supplementary problems for practice, including displaying even numbers and printing a countdown.

Uploaded by

dishuu2001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like