The Program Development Workflow, Explained with Code Examples

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

← Algorithm Design PrinciplesNext lesson: Why ANSI Compliance Exists →

Earn 3 college credits for Programming in CRecommended for credit by NCCRS · Computer Science 240 · self-paced · one payment, lifetime access

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.

Compare: C vs C++

Why take it here

Why students take Programming in C with UPI Study

How programs work close to the machineProgramming in C teaches how a program uses memory: variables and data types, control flow, functions, arrays and strings, pointers, files, structures and dynamic memory. C is the base for operating systems, embedded devices and many computer-science courses.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

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.

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?
The C preprocessor handles every line beginning with a hash sign before the compiler sees the code. For #include <stdio.h>, it pastes in the header that describes tools such as printf, so the compiler knows they exist. Because of that pasting, an eight-line source file can grow to hundreds of lines. With Clang or GCC, the -E option stops after this step and shows the result.
What is an object file in C?
An object file, usually ending in .o, is the compiler's machine-code output before linking. It holds the code for the functions defined in that source file, plus holes for anything defined elsewhere, such as printf from the C standard library. An object file cannot run by itself. The linker fills each hole with the matching piece and produces the executable. The -c option asks for the object file alone.
What is the difference between a compile error and a link error?
A compile error comes from the compiler and means the code breaks C's rules, such as its grammar, while a link error comes from the linker and means a needed piece is missing. If a function is promised with a prototype and called but never defined, compiling succeeds, but linking fails with an undefined symbol message. Because C is case-sensitive, defining Bonus when the code calls bonus causes exactly this kind of link error.
How should a test case be written for a C program?
A test case has three parts: an input, the expected output worked out by hand before running, and the actual output the program prints. Test normal values and edges. A cost rule of two tokens per game shows why: an input of two gives four whether the code adds two or multiplies by two, so only inputs like zero and five reveal the wrong operator.

About the Programming in C course

How many college credits is Programming in C?
Programming in C (Computer Science 240) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Programming in C cost and what is included?
$250, paid once, with lifetime access: all 78 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Programming in C take?
It is self-paced with no deadlines. The 78 lessons total about 9 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

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.

Programming in C
3 credits · NCCRS
Enroll →