Structured Programming Technique-Advantages and Disadvantages
Structured programming is a programming technique in which a program is divided into small units called modules or subprograms. Each module consists of different instructions to perform a particular task. It is executed when the main program calls it.
Structured programming languages are designed to help programmers write code efficiently. They provide tools to organize their code into logical blocks, such as loops or functions. These features allow programmers to focus on writing the logic instead of having to worry about formatting their code. They also offer features such as type checking, error reporting, and debugging.
Instructions used in Structured Programming
The following type of instructions are used in this technique
These types of instructions execute only once in the same order in which they are written. All instructions are executed from top to bottom.
Conditional / Selective Structure
This type of structure executes one or more instructions on the basis of a given condition. Instruction followed by the condition is executed only if the given condition is true. If the condition is false, the control moves to the next instruction. For example, you may want to display “Pass” if the marks are greater than or equal to 40 and “Fail” if the marks are less than 40.
Iterative / Repetitive Structure:
This type of structure executes one or more instructions again and again. The execution continues while a given condition remains true. For example, you may want to display a message ten times, etc.
Advantages of Structured Programming
Some advantages of structured programming are as follows:
Structured programming allows you to reuse the existing code as and when required. You can write frequently used code in a block and give it a specific name. This code can be used again and again without writing the same code again.
Easier to Code
It is easier to write small blocks of code instead of writing a long program as a whole. You can focus your attention on a specific problem in a particular block.
Easier to Modify
Each block of code has a unique name and is written separately from other codes. So it is easier to modify than a long program.
Easier to Maintain
Small blocks are comparatively easier to maintain as compared to long programs. Each block is independent so any change in it does not affect other blocks.
Disadvantages of Structured Programming
In structured programming, data cannot be considered as independent from functions that manipulate it. Procedural programming prevents the programmer from separating data from functions.