0
0
Intro to Computingfundamentals~10 mins

Functions (reusable code blocks) in Intro to Computing - Flowchart & Logic Diagram

Choose your learning style9 modes available
Process Overview

A function is like a small machine inside a program that does a specific job. You can use it many times without rewriting the same steps. This flowchart shows how a program calls a function, the function runs its steps, and then the program continues.

Flowchart
Call Function
Enter Function
Execute Function Steps
Yes No
Return Result
Continue Main Program
This flowchart shows the process of calling a function, executing its steps, checking if it is done, returning the result, and continuing the main program.
Step-by-Step Trace - 6 Steps
Step 1: Start the program and call the function named 'greet'.
Step 2: Enter the function 'greet' and start executing its steps.
Step 3: Execute the function steps: print 'Hello, friend!'.
Step 4: Check if the function has completed all its steps.
Step 5: Return from the function to the main program.
Step 6: Continue executing the main program after the function call.
Diagram
Main Program
+----------------+
|                |
| Call 'greet'   |
|                |
+--------+-------+
         |
         v
+----------------+
| Function 'greet'|
| - Print message |
+----------------+
         |
         v
+----------------+
| Return control  |
+----------------+
This diagram shows the main program calling the function 'greet', the function printing a message, and then returning control back to the main program.
Flowchart Quiz - 3 Questions
Test your understanding
What happens when a function is called in a program?
AThe function deletes the program.
BThe program stops running completely.
CThe program runs the code inside the function.
DThe program ignores the function.
Key Result
Functions let programs reuse code by running a set of instructions whenever needed, making programs easier to write and understand.