UPI Study › Courses › Programming in C › Free lessons › Lesson 1.6 Free with a free account
The Program Development Workflow
Programming in C · Chapter 1: Programming Fundamentals, Pseudocode, and Program DevelopmentSection 1.6 · lesson 6 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: Why ANSI Compliance Exists →← Algorithm Design PrinciplesNext lesson: Why ANSI Compliance Exists →
In this lesson
Edit, preprocess, compile, link, run, test and debug a C program.
- Describe each stop of the C workflow from editing to debugging
- Explain what an object file is and how the linker completes it
- Tell syntax, link, logic and runtime errors apart by where they appear
- Design test cases with expected and actual output and debug step by step
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,143 words). Read along, or search it.
The Big Picture
An Assembly Line for Code
You type one short command, and a second later, a brand-new program appears. Behind that second, your code went through an assembly line. Every trip around it is called the development workflow. Edit, preprocess, compile, link, run, and test. And when a test fails, debug, and go around again. Knowing the stops is a superpower. When something goes wrong, the message tells you which stop complained, and that tells you where to look.
Stop One
Editing and Saving Source Code
Stop one is edit. You type your code, called source code, and save it in a file whose name ends in dot c. Here's a small one for Starlight Arcade. It shows today's best score on Space Dash, and who set it.
Stop Two
The Preprocessor Pastes Headers
Stop two is the preprocessor. It handles every line that starts with a hash sign. For include stdio dot h, it pastes in a file that describes tools like printf, so the next stop knows they exist. Ask Clang to stop after this step, with dash capital E, and count the lines. The file has eight. The preprocessed text has over five hundred. That is a lot of pasted text.
Stops Three and Four
Compiling and Linking Together
Stops three and four come together. The compiler checks your grammar, and translates your C into machine code. The linker joins that machine code with ready-made pieces, such as the real printf, into one program you can run. Run Clang. It prints nothing at all, and for a compiler, silence is good news: every build stop worked. Dash o picks the program's name. Then dot slash high score runs the program in this folder.
Common Mistake
Running Without Recompiling
Now the classic mistake. Priya beats the record, so she changes forty-two hundred to fifty-one hundred, saves, and runs the program again, without compiling. It still says forty-two hundred. The program file is a separate thing, made from the old code, and it hasn't changed. Every change needs a fresh compile. Save, compile, then run. Now it shows fifty-one hundred.
Object Files
Holes the Linker Fills
So what does the compiler hand over to the linker? Ask for that step alone, with dash c, and you get an object file, ending in dot o. It's real machine code, with holes wherever you used something that lives elsewhere. List its names: main is defined here, but printf is marked U, undefined. That's a hole. Try to run the object file, and the system refuses. The real printf is already written. It lives in the C standard library, a big collection of ready-made tools that comes with every C compiler. The linker fills each hole with the matching piece. Link the object file, and now it runs. With one ordinary command, these in-between files are made in a temporary folder and thrown away. You're about to see one, by name.
Kinds of Bugs
Syntax, Link, Logic and Runtime
A mistake in a program is a bug, and fixing bugs is debugging. Each kind of bug is caught at a different stop, from loudest to quietest. A syntax error is caught by the compiler: broken grammar. A link error is caught by the linker: a missing piece. A logic error is caught only by testing: the program runs, but gives wrong answers. And a fourth kind, a runtime error, makes a running program crash partway through. You'll meet those later in the course.
Syntax Error
A Missing Semicolon at Column Forty
Here's a syntax error. Can you spot the missing semicolon before Clang does? No program is made, so there's nothing to run. Read the first line of the message: the file, line five, column forty, error, expected a semicolon after expression. Column forty is the spot right after tokens and its closing bracket, where the caret points. Add the semicolon, compile again, and it builds and runs. Two habits help. With several errors, fix only the first, then compile again. And a warning still makes a program, but read it: it means, this looks risky.
Link Error
A Promised Function Nobody Wrote
Sometimes the grammar is perfect, but the linker can't find a piece. Line three promises a function called bonus. Promises like this are called prototypes; you'll write them in chapter six. But nobody ever wrote bonus. Compile alone, with dash c, and there's no complaint: the compiler trusts the promise, and leaves a hole. Build the whole program, and the message comes from l d, the linker, not the compiler. Undefined symbols: bonus, referenced from main. The object file has an odd temporary name that changes every run. That's the in-between file, caught by name. The fix is simple: write the missing function.
Testing
Expected Versus Actual Output
Logic errors never cause a message, so you catch them by testing. A test case is one planned check with three parts. An input, the expected output, worked out by hand before running, and the actual output, what the program really prints. Here, each game of Space Dash costs two tokens. Priya tried two games, saw four tokens, and was sure it worked. Sam, who tests the arcade's software, fills in the expected column first. Five games at two tokens each is ten. The program says seven. Zero games, expected zero, actual two. Only Priya's input passed, because two plus two and two times two are both four. Test normal values, and edges.
Debugging Routine
Reproduce, Narrow, Fix, Retest
A failing test says that something is wrong. Debugging finds out where. Instead of changing random lines, follow a calm routine. Reproduce it: find an input that fails every time. Five games gives seven, every time. Narrow it down: which line makes the number? Only line eight computes the cost. If you can't tell, add a temporary printf to show a value. Fix one thing: plus becomes times, and nothing else. Then rebuild, and retest everything, including the test that passed before. Run it again. Five gives ten. Zero gives zero. And two still gives four. Every row passes: one full trip around the workflow.
Quick Check
Bonus Versus Capital B Bonus
Quick check. This time Priya does write the bonus function, at the bottom of the file. She promises bonus, and calls bonus, but defines it as Bonus, with a capital B. Then she builds the program. What happens: the compiler stops with a syntax error, the linker fails with a link error, or it runs and prints, bonus nine? Pause, and decide. It's a link error. C is case-sensitive, so Bonus, with a capital B, is a different name. Build it, and the linker reports the missing piece: undefined symbols, bonus, referenced from main. The compiler was satisfied, because bonus was promised. But the linker finds no piece named bonus. There's no syntax error: every line is good grammar. And it would run only if the two names matched exactly.
Key Takeaways
Every Stop and Its Errors
To sum up. The workflow is edit, preprocess, compile, link, run, test, and debug. The compiler leaves holes in an object file, and the linker fills them from the standard library. Syntax errors come from the compiler, link errors from the linker, and logic errors only from testing. And a test compares an expected result, worked out first, with the actual one.
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 The Program Development Workflow
What does the C preprocessor do?
What is an object file in C?
What is the difference between a compile error and a link error?
How should a test case be written for a C program?
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 →