The goal of structured programming is to? (a) have well indented progr...
The main goal of structured Programming is to get an understanding about the flow of control in the given program text. In structure programming various control structures such as switch case. If then – else, while, etc.
Allows a programmer to decode the flow of the program easily.
This question is part of UPSC exam. View all GATE courses
The goal of structured programming is to? (a) have well indented progr...
Goal of Structured Programming:
The goal of structured programming is to improve the clarity, maintainability, and efficiency of computer programs. It emphasizes the use of structured control flow constructs as opposed to unstructured ones, such as the infamous GOTO statement. By adhering to certain principles and guidelines, structured programming aims to make programs easier to read, understand, modify, and debug.
1. Well-Indented Programs:
One aspect of structured programming is the use of proper indentation. Although well-indented programs are not the sole goal of structured programming, they do contribute to the overall readability and maintainability of the code. Indentation helps visually distinguish different blocks of code, making it easier to follow the program's logic.
2. Inferring Flow of Control:
Structured programming aims to make the flow of control within a program explicit and easily understandable. There are two aspects to this:
- From the Compiler Code: Structured programming encourages the use of control flow constructs such as loops, conditionals, and subroutines. These constructs provide clear indications of the program's control flow, making it easier for the compiler to analyze and optimize the code.
- From the Program Text: Structured programming also emphasizes writing code in a way that the flow of control can be inferred directly from the program text. This means avoiding complex and convoluted control structures that make it difficult to understand the program's logic at a glance.
3. Avoidance of GOTO Statement:
One of the key principles of structured programming is to avoid the use of the GOTO statement. The GOTO statement allows unstructured jumps in the program, making it difficult to predict and understand the flow of control. It often leads to spaghetti code, where the logic becomes tangled and hard to follow.
By avoiding GOTO statements, structured programming promotes the use of structured control flow constructs like loops, conditionals, and subroutines. These constructs provide clear entry and exit points, making the program's control flow more explicit and understandable.
Conclusion:
In summary, the goal of structured programming is to improve the clarity, maintainability, and efficiency of computer programs. It aims to achieve this by promoting well-indented programs, enabling the inference of flow of control from both the compiler code and the program text, and avoiding the use of unstructured constructs like the GOTO statement. By following these principles, structured programming helps developers create more readable, understandable, and maintainable code.