C Loops
What is loop?
In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.
(কম্পিউটার প্রোগ্রামিং-এ, একটি লুপ হল নির্দেশের একটি ক্রম যা একটি নির্দিষ্ট শর্তে না পৌঁছানো পর্যন্ত ক্রমাগত পুনরাবৃত্তি হয়।)
There is 3 loops in c:
for loop.
while loop.
do while loop.
for loop
syntax of for loop
Example :
Output:
Output:
While loop
The while loop loops through a block of code as long as a specified condition is true.
Syntax of while loop
Example :
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.
do while loop
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
Example :
Output: