C provides following types of loops:
- for loop.
- while loop.
- do-while loop.
- nested loop.
For Loop :
Syntax:
for( initialization; condition; increment/decrement) {
// Statement1
//Statement2
}
where, initialization of variable,
condition is till where you want to execute the statements
increment/ decrement of counter.
while Loop:
Syntax:
while(condition) {
//Statement1
// Statement2
}
where, condition is that till where when you want to execute your statements.
do-while Loop:
Syntax:
do{
//Statement1
//Statement2
}while(condition);
where, condition is till where you want to execute the statements.
Nested Loop:
Syntax:
for( initialization; condition1; increment/decrement) {
// Statements
for( initialization; condition2; increment/decrement) {
//Statement1
//Statement2
}
}
0 Comment(s)