Chapter 130 min read
Introduction to Computer Programming & C Fundamentals
CC102: Computer Programming 1 — St. Cecilia's College–Cebu, Inc.
Released2025–2026
Core MottoDoing ordinary things extraordinarily well
CreatorsMichael John Bustamante
1. What is a Computer & How Does it Work?
A computer is an electronic machine that needs step-by-step instructions (a program) to perform tasks.
Everyday Analogy: The Kitchen Chef
Think of a computer like a fast kitchen helper in a Minglanilla carenderia. The helper cannot cook on their own until you give them a clear recipe (a program). The ingredients are your Input, the cooking process is CPU Processing, and the served dish is your Output!
The 3 Core Parts of a Computer System
Input Unit:How you give data to the computer (e.g., keyboard, mouse, or touchscreen).
Central Processing Unit (CPU):The 'brain' of the computer that follows your instructions and calculates results.
Output Unit:How the computer shows you the results (e.g., monitor screen or printer).
What is a Program?
A program is simply a list of step-by-step instructions given to the computer along with the data needed to complete a task.
2. The Von Neumann Architecture
Proposed by mathematician John von Neumann in 1945, this fundamental design forms the blueprint for almost every modern computer.
Key Principle: Stored-Program Concept
Before Von Neumann, computers had to be physically rewired to change tasks! Von Neumann introduced the idea of storing BOTH program instructions and data inside the same shared memory bank, allowing computers to run any program dynamically.
1. Central Processing Unit (CPU)
Control Unit (CU):The conductor/manager. It fetches instructions from memory, decodes what they mean, and directs data traffic.
Arithmetic Logic Unit (ALU):The mathematician. It performs math calculations (+, -, *, /) and logical decisions (AND, OR, NOT, comparisons).
Registers:Super-fast, microscopic storage cells located inside the CPU to hold tiny pieces of data needed right this millisecond.
2. Main Memory & Bus System
Shared Memory Unit:Holds both program code and active data side-by-side.
System Buses:High-speed electrical pathways that transport signals:
Control Bus:Transmits signals from the CU.
Address Bus:Carries memory addresses pointing where data should go.
Data Bus:Transfers the actual data bytes back and forth.
3. The Fetch-Decode-Execute Cycle
The fundamental engine loop running billions of times per second inside your processor:
1.
Fetch:Get the next instruction from RAM into the CPU.
2.
Decode:The Control Unit figures out what action is requested.
3.
Execute:The ALU or CU carries out the command.
4.
Store:Save results back into registers or RAM.
Classroom Discussion Starter
Why is the 'Von Neumann Bottleneck' a challenge in modern computer architecture?
Takeaway Goal: Because CPU computing speeds grow faster than RAM transfer rates, the single shared data bus becomes a traffic bottleneck while the CPU waits for data to arrive.
3. Computer Memory & Storage Hierarchy
Understanding how computers temporarily hold active C variables versus how they store files permanently.
Primary Memory (Volatile vs. Non-Volatile)
RAM (Random Access Memory):Extremely fast workspace memory. It is volatile, meaning everything disappears when you turn off the power! Your C variables reside here while code executes.
ROM (Read-Only Memory):Non-volatile memory containing permanent boot scripts (like the BIOS) installed by hardware manufacturers.
Secondary Storage (Permanent)
What it is:Non-volatile, high-capacity storage like SSDs, HDDs, and USB flash drives.
Why we need it:Holds operating systems, compiled `.exe` files, and documents permanently even when powered off. Much slower than RAM, but far cheaper per gigabyte.
The Speed vs. Capacity Spectrum
1.
Registers (Fastest, Smallest, Highest Cost)
2.
CPU Cache (L1, L2, L3)
3.
Primary RAM (Fast, Medium Capacity)
4.
Secondary Storage / SSD (Slower, High Capacity, Lowest Cost)
4. Understanding Programming Languages
Humans use languages like Cebuano or English to talk to each other; we use programming languages to give instructions to computers.
What is Syntax?
Syntax means the grammar rules of a programming language. Just like in English where a sentence must end with a period, in C, code lines often end with a semicolon (;). If you break a syntax rule, the computer gets confused and shows a Syntax Error.
Key Qualities of a Good Programming Language
Readability:Easy for humans to read and understand.
Portability:Able to run on different types of computers (Windows, Mac, Linux).
Efficiency:Runs fast without using too much computer memory.
Good Tools:Includes an Integrated Development Environment (IDE) to write, test, and fix code in one place.
5. Three Generations of Computer Languages
Programming languages have evolved from raw machine numbers to human-friendly code.
1. Machine Language (Low-Level)
What it is:The native language of the CPU made entirely of 1s and 0s (binary code).
Pros/Cons:The computer understands it instantly, but it is extremely difficult for humans to write or read.
bash
10110000 011000012. Assembly Language (Mid-Level)
What it is:Uses short word codes called mnemonics (like ADD, MOV, SUB) instead of raw 1s and 0s.
Pros/Cons:Easier than machine language, but still requires deep knowledge of computer hardware.
bash
MOV AL, 61h3. High-Level Language (Human-Friendly)
What it is:Uses English-like words and math signs (like printf, if, +, -).
Examples:C, C++, Java, Python.
Pros:Very easy to learn, easy to fix errors, and works across different computers.
c
printf("Hello World");6. What Makes C So Special?
C was created in 1972 by Dennis Ritchie at AT&T Bell Labs and remains the foundation of modern software engineering.
Did You Know?
Dennis Ritchie created C to help build the UNIX Operating System. Today, major parts of Windows, macOS, Android, Linux, and even smart TV microchips are written in C!
5 Key Characteristics of C
1.
Mother Language:Most modern languages (Java, C++, C#) borrowed their syntax and core concepts from C.
2.
System Language:Used directly to write hardware drivers, operating system kernels, and low-level tools.
3.
Procedural Language:Solves problems step-by-step using routines called functions.
4.
Structured Language:Allows you to break big programs into small, easy-to-manage blocks of code.
5.
Mid-Level Language:Combines the speed and direct memory access of low-level code with the readability of high-level code.
7. Core Elements of C Programs
Before writing full programs, you need to understand the main building blocks of C code.
Essential Language Elements
Variables & Data Types:Memory boxes used to store numbers, characters, or text.
Keywords:Reserved words in C (like int, return, if) that have special meaning to the compiler.
Operators:Symbols used for math (+, -, *, /) and comparisons (==, >, <).
Control Structures:Making decisions (if-else) or repeating code (for, while loops).
Functions:Reusable blocks of code that perform specific tasks.
8. Line-by-Line Breakdown of 'Hello World'
Analyzing the very first program every computer science student writes.
Your First C Program Code
Look at the structured C snippet below to see how headers, main functions, output commands, and returns come together.
Complete Hello World Source Code
Below is the standard C structure. Review each line to understand how preprocessor instructions and main functions work.
c
#include <stdio.h>
int main() {
/* My first program in C */
printf("Hello, World! \n");
return 0;
}#include <stdio.h>
This is a preprocessor directive. It tells the computer to load standard input/output tools (stdio) so we can display text on the screen and read input from the keyboard.
int main()
The main function. This is the starting point of every C program. The execution always begins inside the curly braces { } of main.
/* Comments */
Lines placed inside /
...
/ or after // are notes for human developers. The computer completely ignores them when running the program.
printf("Hello, World! \n");
The printf function prints text onto your screen. The \n moves the cursor to a new line, and the semicolon (;) marks the end of the command.
return 0;
Tells the operating system that the program finished successfully without any errors.
9. Setting Up Your Coding Environment
Tools you need on your computer or phone to start writing and running C code.
Integrated Development Environment (IDE)
An IDE is a software application that combines a code editor, compiler, and debugger in one window.
Recommended Software Options
Desktop/Laptop:Dev-C++ or Visual Studio Code (VS Code) with the GCC compiler.
Mobile Phone / Tablet:Online C Compilers (like Programiz Online C Compiler or Replit) if you do not have a computer at home.