CORE FUNDAMENTALS
Course: Bachelor of Science / Engineering in Computer Science | Module 01: Summary
& Reference Sheet
1. Compilation & Execution Architecture
A C program undergoes a four-stage translation pipeline before execution by the
operating system:
±------------------+ ±------------------+ ±------------------+
| Source Code | —> | Preprocessor | —> | Compiler |
| (program.c) | | Expands #include | | Converts to ASM |
±------------------+ ±------------------+ ±------------------+
|
v
±------------------+ ±------------------+ ±------------------+
| Executable File | <— | Linker | <— | Assembler |
| (a.out / .exe) | | Links Libraries | | Object Code (.o) |
±------------------+ ±------------------+ ±------------------+
Preprocessor: Processes directives prefixed with # (such as #include <stdio.h> and
#define PI 3.14 ), stripping comments and expanding macros into pure source code.
Compiler: Performs lexical, syntactic, and semantic analysis, translating preprocessed
code into target-specific Assembly Language.
Assembler: Converts Assembly mnemonics into binary machine instructions stored as
Object Code ( .o or .obj ).
Linker: Resolves external symbol references by linking object files with standard runtime
libraries (e.g., libc ) to generate the final Executable Binary.
Diagnostic Note: If compilation succeeds without syntax errors but fails during the
final build stage with an "Undefined reference" message, the fault lies in the Linker
stage (missing library or function definition).
2. Structural Anatomy of a C Program
#include <stdio.h> // 1. Standard Input/Output Header
#define TAX_RATE 0.18 // 2. Symbolic Macro Constant
,int main(void) { // 3. Program Entry Point
int quantity = 5; // 4. Variable Declaration & Initialization
float unit_price = 200.0f;
float total_amount;
total_amount = quantity * unit_price;
printf("Total Amount = %.2f\n", total_amount);
return 0; // 5. Exit Status Code (0 = Normal Termination)
}
Key Language Specifications
Symbolic Constants ( #define ): Substituted textually by the preprocessor prior to
compilation; they consume zero runtime RAM and must never be terminated with a
semicolon ( ; ).
Entry Point ( main ): Every hosted C program requires a single main() function where
runtime execution begins.
Precision Specifier ( %.2f ): Formats floating-point output to strictly two decimal
places (e.g., 1000.00 ).
3. Primitive Data Types & Memory Representation
On standard 64-bit LP64/LLP64 architectures, primitive data types occupy fixed byte
widths:
Data Type
Keyword
Storage Size
Format Specifier
Value Range / Precision
Character
char
1 Byte (8 bits)
%c
-128 to 127 (Signed ASCII)
Signed Integer
int
4 Bytes (32 bits)
%d / %i
-2,147,483,648 to +2,147,483,647
Unsigned Integer
unsigned int