420 likes | 603 Views
12-4 Unions. The union is a construct that allows memory to be shared by different types of data. This redefinition can be as simple as redeclaring an integer as four characters or as complex as redeclaring an entire structure. Topics discussed in this section:. Referencing Unions
E N D
12-4 Unions The union is a construct that allows memory to be shared by different types of data. This redefinition can be as simple as redeclaring an integer as four characters or as complex as redeclaring an entire structure. Topics discussed in this section: Referencing Unions Initializers Unions and Structures Internet Addresses Computer Science: A Structured Programming Approach Using C
FIGURE 12-20 Unions Computer Science: A Structured Programming Approach Using C
PROGRAM 12-7 Demonstrate Effect of Union Computer Science: A Structured Programming Approach Using C
PROGRAM 12-7 Demonstrate Effect of Union Computer Science: A Structured Programming Approach Using C
FIGURE 12-21 A Name Union Computer Science: A Structured Programming Approach Using C
PROGRAM 12-8 Demonstrate Unions in Structures Computer Science: A Structured Programming Approach Using C
PROGRAM 12-8 Demonstrate Unions in Structures Computer Science: A Structured Programming Approach Using C
PROGRAM 12-8 Demonstrate Unions in Structures Computer Science: A Structured Programming Approach Using C
PROGRAM 12-9 Convert IP Address to long Computer Science: A Structured Programming Approach Using C
PROGRAM 12-9 Convert IP Address to long Computer Science: A Structured Programming Approach Using C
PROGRAM 12-9 Convert IP Address to long Computer Science: A Structured Programming Approach Using C
12-5 Programming Application In this section, we develop a program that simulates the operation of an elevator. The elevator serves floors from zero (the basement) to the top floor. The elevator is very old and is not fully automatic. When people enter the elevator, they enter their desired floor number. Computer Science: A Structured Programming Approach Using C
FIGURE 12-22 Elevator Structure Computer Science: A Structured Programming Approach Using C
FIGURE 12-23 Elevator Structure Chart Computer Science: A Structured Programming Approach Using C
FIGURE 12-24 Elevator State Diagram Computer Science: A Structured Programming Approach Using C
PROGRAM 12-10 Elevator: main Computer Science: A Structured Programming Approach Using C
PROGRAM 12-10 Elevator: main Computer Science: A Structured Programming Approach Using C
PROGRAM 12-11 Elevator: Initialize Computer Science: A Structured Programming Approach Using C
PROGRAM 12-12 Elevator: Run Elevator Computer Science: A Structured Programming Approach Using C
PROGRAM 12-12 Elevator: Run Elevator Computer Science: A Structured Programming Approach Using C
PROGRAM 12-12 Elevator: Run Elevator Computer Science: A Structured Programming Approach Using C
PROGRAM 12-13 Elevator: Move Computer Science: A Structured Programming Approach Using C
PROGRAM 12-13 Elevator: Move Computer Science: A Structured Programming Approach Using C
PROGRAM 12-13 Elevator: Move Computer Science: A Structured Programming Approach Using C
PROGRAM 12-14 Elevator: Move Up and Move Down Computer Science: A Structured Programming Approach Using C
PROGRAM 12-14 Elevator: Move Up and Move Down Computer Science: A Structured Programming Approach Using C
PROGRAM 12-14 Elevator: Move Up and Move Down Computer Science: A Structured Programming Approach Using C
PROGRAM 12-14 Elevator: Move Up and Move Down Computer Science: A Structured Programming Approach Using C
PROGRAM 12-15 Elevator: Any Up and Any Down Request Computer Science: A Structured Programming Approach Using C
PROGRAM 12-15 Elevator: Any Up and Any Down Request Computer Science: A Structured Programming Approach Using C
PROGRAM 12-16 Elevator: Time Pass Computer Science: A Structured Programming Approach Using C
PROGRAM 12-17 Elevator: Terminate Computer Science: A Structured Programming Approach Using C
12-6 Software Engineering In this section we discuss two important aspects of program design: function coupling and data hiding. Topics discussed in this section: Coupling Data Hiding Computer Science: A Structured Programming Approach Using C
Note Well-structured functions are highly cohesive and loosely coupled. Computer Science: A Structured Programming Approach Using C
Note Stamp coupling should pass only the data needed. Computer Science: A Structured Programming Approach Using C
Note Don’t bundle unrelated data to reduce the number of parameters. Computer Science: A Structured Programming Approach Using C
Note Control coupling should be used only to pass status. Computer Science: A Structured Programming Approach Using C
Note Avoid global coupling within a program. Computer Science: A Structured Programming Approach Using C
Note Never use content coupling. Computer Science: A Structured Programming Approach Using C
Note Programming Standard: Do not place any variables in the global area of a program. Computer Science: A Structured Programming Approach Using C