Structured Programming Constructs
It uses only three constructs -
1. Sequence (statements, blocks)
2. Selection (if, switch)
3. Iteration (loops like while and for)

Sequence:
1. Any valid expression terminated by a semicolon is a statement.
2. Statements may be grouped together by surrounding them with a pair of curly braces.
3. Such a group is syntactically equivalent to one statement and can be inserted where ever
4. One statement is legal.


Selection:
The selection constructs allow us to follow different paths in different situations. We may also think of them as enabling us to express decisions.
The main selection construct is:
if (expression)
statement1
else
statement2

statement1 is executed if and only if expression evaluates to some non-zero number. If expression evaluates to 0, statement1 is not executed. In that case, statement2 is executed.
If and else are independent constructs, in that if can occur without else (but not the reverse).Any else is paired with the most recent else-less if, unless curly braces enforce a different scheme. Note that only curly braces, not parentheses, must be used to enforce the pairing parentheses

Iteration:
Looping is a way by which we can execute any some set of statements more than one times continuously.In C there are mainly three types of loops are used :
1. while Loop
2. do-while Loop
3. for Loop
The control structures are easy to use because of the following reasons:
1. They are easy to recognize
2. They are simple to deal with as they have just one entry and one exit point
3. They are free of the complications of any particular programming language


Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: