CONTROL STRUCTURES / STATEMENTS:
=> A program is nothing but the execution of sequence of one or more instructions.=> Quite often, it is desirable to alter the sequence of the statements in the program depending upon certain circumstances.
(i.e., we have a number of situations where we may have to change the order of execution of statements based on certain conditions)
(or)
=> Repeat a group of statements until certain specified conditions are met.
=> This involves a kind of decision making to see whether a particular condition has occurred or not and direct the computer to execute certain statements accordingly.
=> Based on application, it is necessary / essential
(i) To alter the flow of a program
(ii) Test the logical conditions
(iii) Control the flow of execution as per the selection these conditions can be placed in the program using decision-making statements.
'C' supports mainly three types of control statements:
I. Decision making statements
1) Simple if Statement
2) if – else Statement
3) Nested if-else statement
4) else – if Ladder
5) switch statement
II. Loop control statements
1) for Loop
2) while Loop
3) do-while Loop
III. Unconditional control statements
1) goto Statement
2) break Statement
3) continue Statement
0 comments:
Post a Comment