Home  >  Article  >  What are the three basic structures of structured programs?

What are the three basic structures of structured programs?

青灯夜游
青灯夜游Original
2020-12-02 10:45:2680725browse

The three basic structures are: 1. Sequential structure, each operation in the program is executed in the order in which they appear; 2. Selection structure, the processing steps of the program branch, and they need to be based on certain conditions. Select one of the branches to execute; 3. Loop structure, the program repeatedly performs one or more operations until a certain condition is false (or true) before the loop can be terminated.

What are the three basic structures of structured programs?

Structured programming is the basic principle for detailed design focusing on module function and process design. Structured programming is a subset of procedural programming that uses logical structures in written programs to make understanding and modification more efficient and easier.

Structured programming adopts a top-down, step-by-step refinement design method. Each module is connected through a "sequence, selection, loop" control structure, and has only one entrance and one exit.

The principle of structured programming can be expressed as: program = (algorithm) (data structure).

The algorithm is an independent whole, and the data structure (including data type and data) is also an independent whole. The two are designed separately, focusing on algorithms (functions or processes).

With the development of computer technology, software engineers are paying more and more attention to the expression of the overall relationship of the system, so data model technology has emerged (treating data structures and algorithms as an independent functional module), which is oriented to The prototype of object programming.

There are three basic structures of structured programs: sequential structure, selection structure and loop structure.

What are the three basic structures of structured programs?

1. Sequential structure

The sequential structure indicates that the operations in the program are executed in the order in which they appear. The characteristics of this structure are: the program starts from the entry point a and performs all operations in sequence until the exit point b, so it is called a sequential structure.

2. Selection structure

The selection structure indicates that there are branches in the processing steps of the program, and it needs to select one of the branches for execution based on a specific condition. There are three types of selection structures: single selection, double selection and multiple selection.

3. Loop structure

The loop structure means that the program repeatedly performs one or more operations until a certain condition is false (or true) before the loop can be terminated. The most important thing in a loop structure is: under what circumstances is the loop executed? What operations need to be performed in a loop? There are two basic forms of loop structures: when-type loops and until-type loops.

When-type loop: It means to judge the condition first, execute the loop body when the given condition is met, and the process will automatically return to the loop entrance at the loop terminal; if the condition is not met, exit the loop body and directly reach the process exit. Because it is "execute the loop when the condition is met", that is, judge first and then execute, it is called a when loop.

Until loop: It means that the loop body is executed directly from the entrance of the structure, and the condition is judged at the loop terminal. If the condition is not met, return to the entrance to continue executing the loop body until the condition is true before exiting the loop and reaching the process. At the exit, it is executed first and judged later. Because it is "until the condition is true", it is called a until loop.

The above is the detailed content of What are the three basic structures of structured programs?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What software is flash?Next article:What software is flash?