4-4 inter-function communication
DESCRIPTION
4-4 Inter-Function Communication. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/1.jpg)
Computer Science: A Structured Programming Approach Using C 1
4-4 Inter-Function Communication
Although the calling and called functions are two Although the calling and called functions are two separate entities, they need to communicate to exchange separate entities, they need to communicate to exchange data. The data flow between the calling and called data. The data flow between the calling and called functions can be divided into three strategies: a functions can be divided into three strategies: a downward flow, an upward flow, and a bi-directional downward flow, an upward flow, and a bi-directional flow. flow.
Basic ConceptC Implementation
Topics discussed in this section:Topics discussed in this section:
![Page 2: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/2.jpg)
Computer Science: A Structured Programming Approach Using C 2
FIGURE 4-16 Data Flow Strategies
![Page 3: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/3.jpg)
Computer Science: A Structured Programming Approach Using C 3
The C language uses only pass by value and return to achieve three types of communications between
a calling and a called function.
NoteNote
![Page 4: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/4.jpg)
Computer Science: A Structured Programming Approach Using C 4
FIGURE 4-17 Downward Communication in C
![Page 5: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/5.jpg)
Computer Science: A Structured Programming Approach Using C 5
FIGURE 4-18 Downward Communication
![Page 6: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/6.jpg)
Computer Science: A Structured Programming Approach Using C 6
FIGURE 4-19 Upward Communication in C
![Page 7: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/7.jpg)
Computer Science: A Structured Programming Approach Using C 7
FIGURE 4-20 Upward Communication
![Page 8: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/8.jpg)
Computer Science: A Structured Programming Approach Using C 8
To send data from the called function to the calling function:
1. We need to use the & symbol in front of the data variable when we call the function.2. We need to use the * symbol after the data type when we declare the address variable3. We need to use the * in front of the variable when we store data indirec
NoteNote
![Page 9: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/9.jpg)
Computer Science: A Structured Programming Approach Using C 9
FIGURE 4-21 Bi-directional Communication in C
![Page 10: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/10.jpg)
Computer Science: A Structured Programming Approach Using C 10
FIGURE 4-22 Bi-directional Communication
![Page 11: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/11.jpg)
Computer Science: A Structured Programming Approach Using C 11
FIGURE 4-23 Exchange Function
![Page 12: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/12.jpg)
Computer Science: A Structured Programming Approach Using C 12
FIGURE 4-24 Calculate Quotient and Remainder
![Page 13: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/13.jpg)
Computer Science: A Structured Programming Approach Using C 13
FIGURE 4-25 Quotient and Remainder Design
![Page 14: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/14.jpg)
Computer Science: A Structured Programming Approach Using C 14
PROGRAM 4-8 Quotient and Remainder
![Page 15: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/15.jpg)
Computer Science: A Structured Programming Approach Using C 15
PROGRAM 4-8 Quotient and Remainder
![Page 16: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/16.jpg)
Computer Science: A Structured Programming Approach Using C 16
PROGRAM 4-8 Quotient and Remainder
![Page 17: 4-4 Inter-Function Communication](https://reader034.vdocument.in/reader034/viewer/2022051401/56812cfc550346895d91ce82/html5/thumbnails/17.jpg)
Computer Science: A Structured Programming Approach Using C 17
PROGRAM 4-8 Quotient and Remainder