UPI Study › Courses › Programming in C › Free lessons › Lesson 1.4 Free with a free account
Writing Pseudocode for Program Design
Programming in C · Chapter 1: Programming Fundamentals, Pseudocode, and Program DevelopmentSection 1.4 · lesson 4 of 788 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: Algorithm Design Principles →← Programming Logic and SyntaxNext lesson: Algorithm Design Principles →
In this lesson
Plan programs in plain words, refine them and desk-check them.
- Write pseudocode with the INPUT, SET, DISPLAY, IF and WHILE keywords
- Apply stepwise refinement to turn vague steps into exact ones
- Desk-check a plan by hand, including edge cases
- Translate pseudocode into C and compare it with a flowchart
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 (1,129 words). Read along, or search it.
Opening Idea
Draw the Plan Before Building
Nobody builds a house by pouring concrete and hoping. First comes a drawing on paper, where moving a wall costs nothing but an eraser. Programmers have their own version of that drawing. Before Priya, who writes the arcade's software, types a single line of C, she writes the plan in careful, plain words. That habit saves her hours of fixing later. So what does a good plan look like, and how does it turn into code?
Definition
A Plan in Plain Words
That plan is called pseudocode: a step-by-step description of a program, in plain words, for people to read. Pseudo means pretend. It looks a bit like a program, but no computer runs it, and no compiler checks it. That freedom is the point. You think only about the logic, what should happen and in what order, without worrying about semicolons and braces. Anyone can read it, including Sam, who tests the software and doesn't need C to spot a missing step. And the same plan could later become C, Python, or anything else.
Why It Pays
Mistakes Are Cheaper on Paper
Pseudocode sits between the problem and the code. A mistake caught on paper is fixed with a few words. The same mistake caught after coding means hunting, editing, and compiling again.
Conventions
Five Capitalized Keywords
Because no compiler checks it, there's no single official way to write pseudocode. Programmers follow conventions: habits most people agree on. These lessons use five keywords in capitals. INPUT gets a value from the user. SET, TO, stores a value in a named box. DISPLAY shows something on the screen. IF, THEN, with ELSE and END IF, does some steps only when a condition is true. And WHILE, with END WHILE, repeats steps while a condition stays true.
Writing Habits
One Action Per Line, Indented
Around those keywords, four habits do most of the work. Write one action per line. Indent the steps that belong inside an IF or a WHILE, so the shape of the plan shows at a glance. Use meaningful names, like dollars and tokens, never d or x. And leave out every language detail: no semicolons, no braces, no printf.
Good and Bad Examples
Too Vague or Too Much Like C
Here are three versions of one plan. Too vague: get the money, do the tokens, maybe add a bonus. Nobody could code that. Too much like C: scanf, t equals d times four, and so on. Only a C programmer can read it, and d and t say nothing about their job. Good pseudocode sits in the middle: exact enough to code from, and plain enough for anyone to check. And watch for the common mistake both ways. If your plan has semicolons or percent d in it, you're already coding. If a line says handle it, ask: how, exactly?
Stepwise Refinement
Breaking Down the Bonus Rule
Now a real request from the arcade's owner. Every dollar buys four tokens. A player who spends ten dollars or more gets five bonus tokens on top. Priya's first draft is three lines: input dollars, work out the tokens, display dollars and tokens. The middle line is too vague to code. So she breaks it into smaller, exact steps. Replacing a big, fuzzy step with smaller precise ones, again and again until every line is clear, is called stepwise refinement. Set tokens to dollars times four. If dollars is ten or more, then set tokens to tokens plus five, indented. End if. Then display. Now every line is exact enough to code.
Desk Check
Tracing Nine, Ten and Twelve Dollars
Before any C exists, Sam checks the plan with a desk check: he walks through the steps by hand with sample inputs, and writes down every value. Nine dollars: thirty-six tokens. Is nine ten or more? No, so line four is skipped. Thirty-six. Ten dollars: forty tokens, then yes, so line four runs: forty-five. Twelve dollars: forty-eight, then yes: fifty-three. Line four is indented, so it runs only when the answer on line three is yes.
Edge Case
More Than Ten Versus Ten or More
Priya's first refined plan said: IF dollars is more than ten. Sam always tests the exact edge of a rule, so he desk-checked ten dollars. Forty tokens, no bonus. But the owner said ten dollars or more, so the answer should be forty-five. Priya changed three words on paper, and the bug was gone, before it ever reached C. So always test the edges: for ten or more, try nine, ten, and something bigger.
Quick Check
Desk-Checking Fifteen Dollars
Quick check. A player puts fifteen dollars into the token changer. Desk-check the refined plan. How many tokens at the end: sixty, sixty-five, or seventy-five? Pause, and decide. Sixty-five. Fifteen times four is sixty, and fifteen is ten or more, so line four adds five. Sixty forgets the bonus. Seventy-five gives five bonus tokens for every dollar, but the plan adds five only once. Only sixty-five matches the plan.
Translation
Turning Each Plan Line Into C
With a checked plan, writing the C is mostly translation. Each pseudocode line becomes one or two lines of C, and C adds the grammar. INPUT becomes a prompt with printf, plus scanf. SET becomes tokens equals dollars times four. Is ten or more becomes greater than or equal to ten, inside an if. END IF becomes a closing brace, and DISPLAY becomes printf. Priya keeps each pseudocode line as a comment above its C. Run it: twelve dollars gives fifty-three, ten gives forty-five. Both match Sam's desk check.
Flowcharts
Shapes, Arrows and a Diamond
Some people think better in pictures. A flowchart draws the same plan as shapes joined by arrows, and each shape has one job. Start. Input dollars. Set tokens to dollars times four. Then a diamond asks the question: dollars ten or more? A diamond has two exits. Yes leads to the bonus step. No skips it. Both paths meet again before the total is shown, and then the flowchart ends. Pseudocode is quicker to write and easy to turn into code. A flowchart makes branching paths easy to see.
Quick Check
A Score That Ties the Record
Quick check. A new plan: if the score is more than the record, display NEW HIGH SCORE. Else, display try again. The record is eight twenty, and a player scores exactly eight twenty. What does the plan display? Pause, and decide. Try again. Eight twenty is not more than eight twenty, so the IF answers no, and the ELSE step runs. NEW HIGH SCORE would need a score above the record. And with an ELSE, one of the two lines always runs, so it never displays nothing.
Key Takeaways
Plan, Refine, Check, Translate
To sum up. Pseudocode is a plan in plain words: no compiler, just logic. Write one action per line, with capital keywords, indents, and meaningful names. Refine fuzzy steps until each is exact, then desk-check by hand, especially at the edges. Then translate line by line into C, or draw it as a flowchart.
Think About It
Pseudocode for a Gold Badge
Something to think about. The arcade wants a rule: a player who scores over nine hundred on a birthday gets a gold badge. Write it in pseudocode with the five keywords. Which inputs will you desk-check, so that every edge is tested?
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 Writing Pseudocode for Program Design
What is pseudocode and why do programmers write it?
What is stepwise refinement?
What is a desk check in programming?
What is the difference between pseudocode and a flowchart?
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 →