Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




Structured Programming

In structured programming, the program is divided into small parts (functions) and each part performs a specific job. The main importance is on functions rather than data. The same data can be used and manipulated by several functions and such type of data is made global.

Structured Programming Constructs:


1.    Sequence Control Structure (Sequence Logic or Sequential Flow).
2.    Selection Control Structure (Selection Logic or Conditional Flow).
3.    Repetition Control Structure (Iteration Logic or Repetitive Flow).

1.    Sequence Control Structure (Sequence Logic or Sequential Flow):

If nothing is specified then the modules the executed in the sequence in which they are written. Thus in it the modules are executed one after the other.

The sequence control structure is shown below:

Algorithm                            
    
.
    .
    .
Module A

Module B

Module C
    .
    .
    .
2.    Selection Control Structure (Selection Logic or Conditional Flow):

In it there are various conditions on the basis of which one module is selected out of several given modules. The structures which implement this logic are called conditional structures. The conditional structures can be divided into following categories:

1.    Single Alternative: This structure has the following form:

If condition, then:
[Module A]

[End of If structure]
According to this if the condition is true then module A is executed. Otherwise, module A is skipped. Its flowchart is:


2.    Double Alternative: This structure has the following form:


If condition, then:
[Module A]
Else:
[Module B]
[End of If structure]


3. Multiple Alternative: This structure has the following form:


If condition (1), then:
[Module A1]
Else If condition (2), then:
[Module A2]
.
.
.
Else If condition (n), then:
[Module An]
Else:
[Module B]
[End of If structure]

According to this only one of the modules will be executed. If condition 1 is true then module A1 will be executed. Otherwise condition 2 will be checked. If condition 2 is true then module A2 will be executed. And so on. If none of the conditions is true then module B will be executed. Its flowchart is:

4. Repetition Control Structure (Iteration Logic or Repetitive Flow): In it loops are implemented. Loop is used to implement those statements which are to be repeated again and again until some condition is satisfied. It implements while and for loops. Each of these begin with Repeat statement. For example is case of Repeat-while structure:

Repeat steps 1 to n while condition:
[Steps]
[End of Repeat-while structure]

Its flowchart is:

Share this article   |    Print    |    Article read by 7018 times
Author:
Rohit kakria
I am software developer, moderator of xpode.com
Related Articles: No related article
Related Interview Questions: No related interview question