Loops are control structures that
enable repetitive execution of a block of code until a specific condition is
met. They allow you to execute a set of statements multiple times, iterating
over a sequence of instructions as long as the given condition holds true.
We have three types of looping statements:
- For loop
- While loop
- Do-While loop
For loop:
It is an entry controlled loop.
It Contains three parameters-
for( initialization ; condition ;
increment )
{
}
A program using nested loops to print
the following pattern is as follows:
*
* *
* * *
* * * *
* * * * *
While loop:
It is also an entry controlled loop.
Here is a program to print the table of 50 using while loop
Do while loop:
It is an exit controlled loop.
Here is a program to find the sum of 10 numbers using do while loop
1 Comments
great job
ReplyDelete