Structured vs Procedural vs Oriented Programming

Structured  Programming is a set of quality standards that make programs more readable, reliable, and easily maintained. Structure programming is a programming in which the programmer divides his program’s source code into logically structured chunks of code, these logically structured chunks of code are called modules(functions). And this programming follows sequential flow, decisional flow,  repetition flow, etc.

Structured programming follows some standard or rules these rules are given below:

If program or project is too complex then it should be broken down into several functions or modules. And after the completion of module control of the program should be brought back to the same line from where it was called.

For example suppose we have to make a program that has to perform 3 tasks, for performing these three task we can break our main program into 3 separate modules(functions) so that it’s complexity can be reduced. If these 3 task are too complex then each separate task can further be broken down into sub modules(or functions). The process of dividing a program into functions(modules) is called modularization.

In structured programming for the repetition of similar statements we don’t need to write statements again. Just we use loops like for, while, do-while, etc to repeat similar statements.

For example, suppose we have to repeat a=b+c;, b=c*d; 10 times then we will just execute either for, while, do-while, etc, loop for 10 times & put the above two statements inside the loop.

For(i=1;i<=10;i++)
{
a=b+c;
b=c*d;
}

The statements of structured programming  are executed in a sequence as they are placed in program.

For example suppose in a program we have written following 3 lines

a=b+c
c=b
b=a

Then control of program will be transferred in a sequence form line 1 to line 3. And generally the control of program  is transferred line by line until function call, loops, or decision control statements are encountered.

For taking decision, decision control structure is used. Decision control structure contains if, if-else, nested if-else, switch, etc.

All the relevant statement are blocked together.

For example to generate Fibonacci series we have to repeat these a=b+c; c=b; b=a;

Three statements. Above three statements are relevant because by the execution of three statements we can produce Fibonacci series so we put them together in the opening or closing block of loop Like below:

For( ; ;	)
{
a=b+c; 
c=b; 
b=a;
}

Approch of Structured Programming

Structured programming follows a Top-Down or Bottom-Up approach of programming.

Top Down approach of Programming:

In this approach overall program or project is decided initially. It has been also decided that how many modules(functions) the program will have, then the main module is broken down into several modules and finally these modules are written. The top-Down approach is a programming style where design begins by specifying high-level elements and then dividing them into smaller and more detailed pieces called functions(modules). As the elements of the application become smaller and lower level they are specific enough to be coded and the application can be written. The technique for writing a program using top-down programming methods is to write the main function(module) that names all the major functions it will need. When all the various functions(module) have been coded the program is done.

For example: Below is the diagram where it has been decided that the main module(function) would have three modules named module 1, module 2, and module 3 then coding(statements) of modules are written. For further refinement module, 1 is also broken down into sub-module 1 and sub-module 2.

Top down approach

Bottom-Up Approach of Programming:

In this approach first programmer has to write code for modules. Then they look for integration of these modules. At last, it concentrates on the abstract of over all system or project. The bottom-up approach is more suitable for a project or system which is going to start from some existing modules.

For example in the below diagram at first module 1, module 2, and module 3 are written or coded then finally these three modules are integrated into the main module.

bottom up approach