C Programming loops
Welcome to c programming learning
Looping statement are most popular for writing any because if we want to make iteration in a program must we need looping statements that's why looping statements are playing key role in the coding.
Now let's move on to looping statements
Looping statements are
1. For loop
2.while loop
3.do-while loop
These three we use for iterations in coding....
1. For loop
For loop consist of three simple statements in the for loop two brackets.
Syntax:
for(assignment statement; conditional or control statement; increment or decrement statement)
In the above is syntax for the looping statement of for.
In this one statement that is increment is not there then also it execute. If we using conditional statement must be assignment is done.
If the three statements are not present in the for loop the loop will iterate infinite times. But there must be place the semicolon (;) three times.
If we place semicolon at the end of for loop it won't iterate, it makes only one time execution like if loop
Example---
for(i=0;i<5;i++)
i=0; is assignment
i<5; is condition or control (after false condition it is controlled)
i++; increment statement
for(; ; ;)
this is loop which gives infinite iteration.
for(; ; ;);
This is only one time execution statement.
Because we place semicolon like as simple statement
..
For the remaining looping statements see next post.....✌️
Comments
Post a Comment