What are the three basic structures of structured programs?
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.
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.
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version