Control statements in C allow changing the order of execution based on conditions or repeating a group of statements. The main types of control statements are selection structures like if/else which execute one or the other block based on a condition being true or false, and looping structures like while, do-while and for loops which repeat a block of code either indefinitely or a specified number of times. Nested loops can also be used to repeat blocks of code multiple times in both the inner and outer loops.
1 of 76
Download to read offline
More Related Content
Controlstatment in c
1. Control Statement in C
Lecture : 7
Md. Al-Imran Roton
Lecturer, CSEDIU
Bangladesh
3. CONTROL STATEMENT
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.
14. Real life example
If(girl==educated)
{
If(girl==beautiful)
{
If(girl==smart)
I agree to marry her.
Else
Think about consideration.
}
Else
Talk with parents.
}
Else
Rejected .
23. PRACTICE EXAMPLE
Big Bazzar gives festival discount on purchase of
their products in the following percentages
i.If purchase amount < 1000 than 5% discount
ii.If purchase amount >=1000 than but <3000 then
10% discount
iii.If purchase amount >=3000 but <5000 then 12%
discount
iv.If purchase amount > 5000 then 15% discount
v.Make an university grading system.
26. Break Statement
It is an jump instruction and can be
used inside the switch and loop
statements.
The execution of the break statements
causes the control transfer to the
statement immediately after the loop.
30. Continue Statement
It is a jump statement.
It is used only inside the loop.
Its execution does not exit from the loop but
escape the loop for that iteration and
transfer the control back to the loop for the
new iteration.
32. Goto Statement
It is used the alter the normal sequence of flow by
transferring the control to some other part of the
program unconditionally.
It is followed by the label statement which
determine the instruction to be handled next after
the execution of the goto statement.
39. Why Looping
Printf(HA HA );
Printf(HA HA );
Printf(HA HA );
Printf(HA HA );
Printf(HA HA );
Printf(HA HA );
Need to write 6 time printf() function. (problem)
Solution : Repitition/Looping.