2. There are some situations where one may
have to
Change the order of execution based on
certain conditions
OR
Repeat a group of statements until certain
conditions are satisfied.
2
3. For this, C supports some statements which are
capable of decision making, they are:
1. If statement
2. Switch statement
3. Conditional Operator
4. Goto Statement
5. While loop
6. Do-While loop
7. For loop
3
7. It is used for an unconditional jump
Syntax
(forward jump) (backward jump)
goto label; label:
…………….. Statement;
…………….. ………………
Label: ………………
Statement; goto label;
Programmers avoid using this
As this statement makes logic complicated and
debugging is difficult.
7
8. An Entry Controlled loop
Syntax
while(test condition)
{
Body Of the Loop
}
8
9. An Exit Controlled loop
Syntax
do
{
set of statements
}
while(condition);
9
10. An Entry Controlled Loop
Syntax
for(initialization ; test-condition ; increment)
{
BODY OF THE LOOP
}
10