Input/Output Examples in CS Thinking
Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Input/Output.
This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.
Concept Recap
The mechanisms by which a program receives data from the outside world (input) and sends results back (output). Input can come from keyboards, files, sensors, or network connections; output can go to screens, files, printers, or other devices.
What goes in and what comes out. Keyboard → program → screen.
Read the full concept explanation →How to Use These Examples
- Read the first worked example with the solution open so the structure is clear.
- Try the practice problems before revealing each solution.
- Use the related concepts and background knowledge badges if you feel stuck.
What to Focus On
Core idea: Programs are useless without I/O—they transform input into output.
Common stuck point: Input needs validation—users may enter unexpected or invalid values that crash the program.
Sense of Study hint: When handling input, always validate and sanitize what you receive before using it in your program. Check for the correct type, reasonable range, and proper format. When producing output, format it clearly so the user or receiving system can understand and use it.
Worked Examples
Example 1
easySolution
- 1 Step 1: Inputs are data the program receives from the user. Here there are two inputs: name and age.
- 2 Step 2: The OUTPUT statement displays a message to the user — this is the program's output.
- 3 Step 3: The program takes two inputs (name and age) and produces one output (a greeting message).
Answer
Example 2
mediumPractice Problems
Try these problems on your own first, then open the solution to compare your method.