Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Structured Design Using Flowcharts, Lecture notes of Design

and impossible to debug if not implemented using a structured design process. There are ... following benefits: ... Figure 3: Derived Flowchart Structures ...

Typology: Lecture notes

2021/2022

Uploaded on 08/05/2022

nguyen_99
nguyen_99 🇻🇳

4.2

(82)

1K documents

1 / 9

Toggle sidebar

Related documents


Partial preview of the text

Download Structured Design Using Flowcharts and more Lecture notes Design in PDF only on Docsity! Structured Design Using Flowcharts C Code Implementation Revision 2.0 December 2001 Andrew J. Blauch Paul D. Johnson Padnos School of Engineering BACKGROUND Simple programming exercises can often be solved by just sitting down and writing code to implement the desired problem. Complex problems, however, can be difficult to write and impossible to debug if not implemented using a structured design process. There are many structured design methodologies that can be used to implement programs and solve other types of engineering problems. Using a structured design process leads to the following benefits: • Early detection of design flaws • Programs that can be easily modified • Clear and complete documentation • Modular design to improve testing • Modular design to break up problem into smaller sections The application of a structure design methodology greatly increases the probability of completing a successful design with a minimum amount of time and expense. By using a structured design methodology, the likelihood of finding design flaws early improves considerably. Finding design flaws early in the design process greatly reduces the cost of fixing those flaws. A programming problem that might be fixable for a few dollars early in the design process might cost many thousands of dollars to repair when the flaw is not detected until the project is near completion. Structured design methods also improve the ability to modify programs at a later date since the techniques make the production of clear and complete documentation much easier. Structured designs can also be more easily broken up into modules to improve testing and to allow development by multiple design teams with a reasonable assurance that the resulting products will be compatible with each other. Derived Structures Although all flowcharts can be represented by the above basic structures, it is sometimes useful to employ some additional structures, each of which can themselves be constructed from the above structures. These derived structures are shown in Figure 3. DO-WHILE structure CASE structure The DO-WHILE structure differs from the WHILE structure in that the process contained within the loop is always executed at least one time. This is equivalent to performing the process once before going into a WHILE loop. In the WHILE structure the process may never be executed. Although the WHILE structure is preferred, the DO-WHILE structure is sometimes more intuitive. Similarly, the CASE structure is useful in representing a series of IF-THEN-ELSE statements where there are more than two choices to be made. Hence the DECISION blocks are identical except for the choice being compared. For example, the DECISION could be ‘is the color of the sock …’ Each DECISION block would then have a different color as the choice. The true result always flows to the right, with the false result flowing into the next DECISION block. There will always be one less DECISION block than the number of choices. Figure 3: Derived Flowchart Structures Examples of Good and Bad Structured Flowcharts Figure 4 shows an example of a properly and improperly structured flowchart. The unstructured flowchart is an example of what can happen if a program is written first and then a flowchart is created to represent the program. This type of unstructured flow is often called 'spaghetti' programming and normally has elements of its structure impossibly intertwined around other elements. A program of this sort is very difficult to understand, implement, debug, and maintain. Unstructured Structured Figure 4: Structured and Unstructured Flowchart Examples FLOWCHART IMPLEMENTATION USING C Writing C code from a structured flowchart is very straightforward. Each type of process structure described previously has a corresponding C code program flow statement. Figures 5 and 6 illustrate the C code implementation of the three basic and two derived process structures. Note that the single process blocks can be implemented with a single line of code, multiple lines of code, a function call, or another group of structured process blocks. WHILE structure SEQUENCE structure IF-THEN-ELSE structure x = 10; y = 9*x/5+32; DispTemp(x,y); if ( x > 5 ) { x = 5; } else { x = 0; } while ( x < 10 ) { x = 2*x; } Initialize Celsius temperature Convert to Fahrenheit Display temperatures Limit voltage to 5 volts Turn voltage off Is voltage greater than 5? Double result Is result less than 10? No Yes Yes No Figure 5: C Code Implementation for Basic Flowchart Structures
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved