2.1 - Basics (2026-08-26)
Overview
Chris Bourke introduces C program anatomy through a miles-to-kilometers converter, then explains how GCC turns source code into an executable and how comments, preprocessor directives, macros, functions, punctuation, and formatting contribute to readable programs. He closes by introducing variable declarations and the range of a 32-bit signed integer, connecting its finite storage to overflow.
Key takeaways
- GCC hides several build stages behind one command: preprocessing, compilation, assembly, and linking ultimately produce the executable.
- In C, // comments end at the next line and /* ... */ comments can span lines; documentation should describe intent rather than repeat what readable code already shows.
- A #define macro gives a meaningful name to a value such as 1.60934 kilometers per mile, reducing magic numbers and making later changes easier.
- C programs begin execution in main, and semicolons terminate executable statements while curly braces delimit code blocks.
- Use double quotes for strings and single quotes for individual characters; ASCII represents characters such as 'S' and space with numeric codes.
- A standard 32-bit signed int has finite limits of roughly -2.147 billion to 2.147 billion, so arithmetic can overflow rather than represent unlimited integers.
Chapters
- Chris Bourke notes that students completed Lab 1 by creating, compiling, running, and submitting a program.
- The Nebraska Union involvement fair runs from 4 to 6 p.m. and features more than 150 recognized student organizations.
- He highlights the Engineering Student Advisory Board, Computing Student Advisory Board, Cornhacks, and the UNL gaming club.
- The program's documentation identifies its author, date, and purpose: read miles from a user, convert them to kilometers, and display the result.
- Clear names such as miles and kms help reveal the program's behavior before examining every C detail.
- Chris Bourke compiles the source with GCC and runs ./a.out; entering 120.5 miles produces about 193.9 kilometers.
- A C source file is plain text, while the executable produced by GCC is binary machine code.
- GCC can emit assembly for inspection, or use the -c option to create an object file without linking.
- A hex dump displays object-file bytes in hexadecimal, including readable strings such as "please enter miles."
- The complete build process includes preprocessing, compilation to assembly, assembling to object code, and linking libraries into an executable.
- Single-line comments begin with //, while block comments use /* and */; both are ignored by the compiler.
- A documentation-style header records the author, date, and program purpose, details Bourke says count toward documentation points on early assignments.
- Useful comments explain what code is intended to do and why, rather than restating operations already obvious from names and statements.
- Bourke calls unnecessary comments and clutter "cruft" and recommends keeping code self-documenting.
- #include directives bring in headers such as stdio.h for input and output functions like printf and scanf; math.h provides functions such as sin and sqrt.
- The #define directive creates a macro that the preprocessor replaces before compilation, as with a kilometers-per-mile conversion factor of 1.60934.
- Naming a conversion factor avoids an unexplained magic number and makes a shared value easier to update in one place.
- The math library provides named constants such as M_PI and M_E, avoiding manually entered approximations.
- The main function is the program's entry point, and its opening and closing curly braces enclose the function's code block.
- Ordinary execution proceeds from top to bottom, while loops and branches provide ways to repeat or redirect that flow.
- Executable statements end with semicolons; Bourke demonstrates that omitting one causes a compiler error.
- Parentheses surround function inputs, as in printf(...), and curly braces group statements into blocks.
- Double quotes delimit strings, which can contain text, digits, and punctuation; single quotes represent a single character such as 'C'.
- ASCII assigns numeric values to characters: Bourke gives 83 for capital S and 32 for a space.
- ASCII control characters such as backspace and line feed reflect conventions inherited from typewriters.
- Commas separate items in lists, while square brackets will later be used for arrays.
- Whitespace is generally optional for C syntax but improves readability when used consistently around code.
- Blank lines visually group related statements, such as declaring variables together and separating that section from input or calculations.
- Indent statements consistently within a block; Bourke demonstrates using a style command to reformat misaligned code.
- Brace placement varies among style guides, so Bourke emphasizes consistency over arguing for one convention.
- C is statically typed in the sense introduced here: declare a variable's type and name before using it, and match its spelling and capitalization.
- The lesson starts with int for whole numbers, double for fractional numbers, and char for a single character.
- A 32-bit signed int has a range of approximately -2.147 billion to 2.147 billion, because its representation uses a finite number of bits.
- Adding beyond an integer's representable range causes overflow, a topic Bourke flags for a later lecture and lab.
Transcript excerpt
0:02 [music] Mom and [singing] dad went to [music] a show. They dropped me off the Grand. [singing] [music] I kick and scream to please me. Grandma take them home. [music] Grandma take home. Heat. Heat. [music] And my dinner [music] stuff couldn't show you. [music] [music]
0:52 [music] >> [music] >> What I [music] gravitate [music] after dinner I had. I scream. I fell asleep and watch TV. [music] Welcome. [music] Gravity. [music]
1:45 [music] Gravity take me home. Gravity take me home. Gravity take me home. [music] Gravity take me home. Gravity [music] take me home. Gravity take me home. Gravity take me home while I [music] be alone. Okay, so everybody had a successful lab one yesterday. There were a few snags, but hopefully we'll work through them. Uh but for the most part, everybody was able to uh go through the process of creating a program, compiling it,
2:31 running it, and handing it in and being graded on it. Uh before we get started today, I want to draw your attention to an event almost immediately after this. It's the involvement fair. Uh so RSOs which are recognized student organizations, clubs, uh things uh you know sports clubs and uh academic clubs and activity clubs, they're all going to be having a um you know over 150 of them are going to be at the Nebraska Union from 4 to 6 tonight or this afternoon. Uh and in particular I I'm going to plug a couple of them like the uh SESAB will probably there be there. ESAB will be there. That's engineering student advisory board and the computing student advisory board. Basically student governance for uh for computing and and engineering respectively. Uh also
3:20 there's going to be cornhacks is going to be there which is our annual
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Chris Bourke.