UPI Study › Courses › Programming in C › Free lessons › Lesson 1.2 Free with a free account
Core Program Structure: Input, Processing, and Output
Programming in C · Chapter 1: Programming Fundamentals, Pseudocode, and Program DevelopmentSection 1.2 · lesson 2 of 787 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Programming in C.
Lesson complete
Earn the 3 college credits for Programming in C
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Programming Logic and Syntax →← Understanding Programming FundamentalsNext lesson: Programming Logic and Syntax →
In this lesson
Every program takes input, processes it and produces output.
- Identify the input, processing and output of a program
- Recognize forms of input and output beyond the keyboard and screen
- Explain how variables, scanf and printf fit the IPO model in C
- Explain why input must come before processing and why input needs checking
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (896 words). Read along, or search it.
Opening Example
Tickets In, a Prize Out
At the Starlight Arcade prize counter, you slide a stack of paper tickets across the desk. The clerk counts them, checks the prize wall, and hands you a yo-yo, plus a few tickets back. Three moments just happened. Something came in, something was worked out, and something came out. Almost every program ever written has that same shape, from a calculator to a giant online game.
The IPO Model
Input, Processing and Output
Those three jobs have names. The tickets you hand over are the input: information that goes into a program from outside. Counting them and choosing a prize is the processing: the work the program does with that information. The yo-yo and the leftover tickets are the output: the results that come back out. This shape is called the I P O model, short for input, processing, output. Information flows one way: in, worked on, out. Once you know it, you can ask three questions about any machine or app. What goes in? What does it work out? What comes out? Keep those three questions handy. They work on almost anything.
Four Examples
Same Shape, Different Processing
Try it on four very different programs. The token changer takes dollars, multiplies by four, and drops tokens into the tray. An arcade game takes the player's final score, compares it with the record, and shows NEW HIGH SCORE. A calculator takes two numbers and a plus sign, adds them, and shows the sum. A thermostat reads the room's temperature, asks whether it's below the setting, and turns the heater on or off. Input and output are what people notice. Processing is what makes each program different.
Input and Output Forms
Buttons, Sensors, Sounds and Files
Input isn't only typing. A press on a button, a coin rolling past a sensor, and a reading from a thermometer are all input. Output isn't only words on a screen. A sound, a flashing light, and a motor pushing out prize tickets are all output. One thing can sit on both sides: a saved high-score file. The game writes it tonight as output, and reads it back tomorrow as input. Your first C programs use the simplest pair. Input is what someone types on the keyboard. Output is text in the terminal window.
Processing
Calculating, Comparing and Sorting
Input and output are the parts people see. Processing is the hidden middle, and it's where the program earns its keep. Most processing is one of three kinds of work, often mixed. Calculating, like dollars times four. Comparing, like asking whether a score beats the record. And sorting, like putting a score table in order. To do any of it, the program must remember values while it runs. It keeps each one in a variable: a named box in memory that holds one value.
Worked Example
The Token Changer in C
Here's a real C program for the token changer, the middle of it. The gray words after two slashes are comments: notes for humans, which the compiler ignores. Each comment names the part that comes next. First two boxes, dollars and tokens. Then printf shows the question, how many dollars? That question is output. A message that asks for input is called a prompt. Then scanf waits until the player types a number and presses Enter, and puts it in the dollars box. That's the input. The line tokens equals dollars times four is the processing. In C, the asterisk means times. Finally, printf shows the answer, filling each percent d spot with a number, in order.
Running It
Five Dollars Buys Twenty Tokens
Run it, and type five. The five travels through the program: typed in, stored in the dollars box, multiplied, stored again, and shown. How many dollars? five. Five dollars buys twenty tokens.
Common Mistake
Processing Before the Input Arrives
A common mistake is putting the steps in the wrong order. A program runs from top to bottom. Move the processing line above scanf, and the program multiplies a number nobody has typed yet. A box never filled holds leftover junk. So the order is always the same: get the input, then process it, then show the output.
Testing Odd Input
Garbage In, Garbage Out
Sam, who tests the arcade's software, tries what a real player might do, including the odd things. He ran Priya's program and typed minus three. The program didn't complain at all. Minus three dollars buys minus twelve tokens. It did exactly what it was told. Programmers call this garbage in, garbage out: if the input makes no sense, the output won't either. The fix is more processing: a step that checks the input before using it. You'll add checks like that with decisions, later in the course.
Quick Check
Changing the Deal to Five Tokens
Quick check. The arcade changes its deal: every dollar now buys five tokens. Priya changes one line. Then a player types six. What does the last line say: thirty tokens, twenty-four tokens, or eleven tokens? Pause, and decide. Thirty tokens. Only the processing line changes, to dollars times five. Six times five is thirty. The input and output lines stay exactly as they were. Twenty-four is the old deal, and eleven adds the numbers instead of multiplying.
Key Takeaways
In, Worked On, Then Out
To sum up. Almost every program takes input, processes it, and produces output. Input and output come in many forms: buttons, sensors, files, sounds and lights. Processing calculates, compares and sorts, and keeps values in variables. And the order is fixed: input first, then processing, then output.
Think About It
What a Phone Alarm Saves
Something to think about. Take the alarm on your phone. What goes in, what does it work out, and what comes out? And is there anything it saves as output tonight, and reads back as input tomorrow?
About Programming in C at UPI Study
Programming in C (Computer Science 240) is a self-paced online course of 78 video lessons in 11 chapters, from pseudocode and your first program to data types, decisions, loops, functions, arrays, strings, pointers, files, structures, dynamic memory and linked lists. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: C vs C++
Why take it here
Why students take Programming in C with UPI Study
Where the credit goes
Universities that work with NCCRS
Programming in C carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Core Program Structure: Input, Processing, and Output
What is the IPO model in programming?
What does garbage in, garbage out mean?
How do scanf and printf fit the input, processing and output stages in C?
Why does the order of input and processing statements matter in C?
About the Programming in C course
How many college credits is Programming in C?
How much does Programming in C cost and what is included?
Which universities accept UPI Study credits?
How long does Programming in C take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Programming in C.
78 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
3 credits · NCCRSEnroll →