loops In C

In this article, I am going to tell about loops in c language. generally what is the meaning of loops?
for what purpose loops are used? I am going to explain all these things in this article with examples


Suppose if you want to print a statement 100 times you cant write printf statement 100 times. you can say it is an impossible event by writing 100 printf statements you are tired and you hesitate to write a remaining program and it is a time-consuming process, In order to remove this process, we will be using loops concept.

With the help of loops, we can iterate a certain statement to ' n '  times. which is a very easy process rather than writing n times printf statement. loops and if-else statements are very important in any language as you are going to use these two concepts in every program

if you write any statement in a loop block, that statement gets iterated until the condition becomes false. concept of loops can be implemented by using three ways

1. for-loop
2. while-loop
3. Do-while loop

we will discuss while loop in this article. look at the following example

In the above example, the statements written in a block executes until the condition( i < 100 ) becomes false. so the above output of the program is " HELLO WORLD " is printed 100 times.
the condition which you want to restrict the iteration of statements is written in btw the parentheses after the while statement.

for better understanding, you can take look at the below example.

Post a comment

0 Comments