In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.
(কম্পিউটার প্রোগ্রামিং-এ, একটি লুপ হল নির্দেশের একটি ক্রম যা একটি নির্দিষ্ট শর্তে না পৌঁছানো পর্যন্ত ক্রমাগত পুনরাবৃত্তি হয়।)
for loop.
while loop.
do while loop.
syntax of for loop
Output:
Output:
The while loop loops through a block of code as long as a specified condition is true.
Syntax of while loop
Output:
In the example, the code in the loop will run, over and over again, as long as a variable (i) is less than 5.
The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.
Syntax of do while loop
Output: