Input & Output
A program that can't communicate is useless. It needs to ask for information (input) and show results (output). Think of it like a conversation: the program asks a question, you type an answer, and the program responds.
Input means getting data from the user (like typing your name). Output means showing data to the user (like displaying a message). In flowcharts, both use the parallelogram shape.
The Parallelogram Shape
You've seen this shape in earlier lessons. The parallelogram (the slanted rectangle) is used for both input and output. The text inside tells you which one it is:
- INPUT name — the program waits for the user to type something and stores it in a variable.
- OUTPUT "Hello!" — the program displays a message to the user.
Example: Personal Greeting
This program asks for your name, builds a greeting message, and displays it. Watch how data flows: in from the user, through a variable, and back out.
BEGIN
OUTPUT "What is your name?"
INPUT name
greeting = "Hello, " + name + "!"
OUTPUT greeting
END
Variable Watch
| Variable | Value |
|---|---|
| Step through to see variables | |
Notice the flow: first the program outputs a question (a prompt), then it inputs the user's answer into a variable, then it processes that data, and finally outputs the result. This pattern — prompt, input, process, output — is extremely common in programming.
Another Example: Add Two Numbers
Here's a program that asks for two numbers and displays their sum.
This follows the same pattern: input data, process it, output the result. Programs are fundamentally about transforming input into output — and now you know how to show that in a flowchart.
Input vs. Output in pseudocode:
INPUT always stores data into a variable.
OUTPUT displays data — it can show a variable's value, a literal string
in quotes, or a combination.
Key Takeaways
- Input gets data from the user and stores it in a variable.
- Output displays data to the user.
- Both use the parallelogram shape in flowcharts.
- A common pattern is: prompt, input, process, output.
- In pseudocode:
INPUT variableandOUTPUT value