Module 1: Introduction to Computers, Programs, and C
This module lays the groundwork, exploring the essential components and concepts.
What is a Computer?
The Central Processing Unit (CPU)
Memory (Random Access Memory or RAM)
And more...
A computer, in its essence, is a device comprising a Central Processing Unit (CPU), memory, storage (like a hard disk), input/output mechanisms, and communication channels. These components work in concert, guided by a mystical 'Bus'.
Key Components:
CPU: The brain, executing instructions.
Memory: Temporary storage for active programs and data.
Storage Devices: Permanent repositories for your digital files (e.g., Disk, CD, Tape).
Input Devices: How you command the machine (e.g., Keyboard, Mouse).
Output Devices: How the machine responds (e.g., Monitor, Printer).
Communication Devices: Bridges to other networks (e.g., Modem, Network Interface Card - NIC).
The CPU is the heart of the computer, retrieving and executing instructions from memory. Its speed, measured in Megahertz (MHz) or Gigahertz (GHz), dictates how quickly it can process spells. Modern CPUs, like the Intel Core series, possess immense computational power.
For example, 1 MHz means 1 million pulses per second, while 1 GHz is 1000 MHz.
Memory (Random Access Memory or RAM) is where your programs and their data reside while being actively used by the CPU. It's an ordered sequence of bytes, each a container for 8 bits of information.
Key Characteristics:
Data must be loaded into memory for execution.
A memory byte always holds some data, though it might be arcane gibberish initially.
New information overwrites the old; memory is ephemeral in this sense.
It is volatile: its contents are lost when power is removed.
All data—numbers, mystical characters, powerful strings—are encoded as series of bits (0s and 1s). This binary system is fundamental because digital devices have two stable states.
Encoding: The system automatically handles encoding (e.g., character 'J' as 01001010).
Bytes: The smallest addressable unit of memory. A single byte can store a small number or a single character. Larger data spans multiple adjacent bytes.
Uniqueness: No two distinct pieces of data can share or split the same byte.
Since memory is volatile, programs and data are permanently etched onto storage devices.
Main Types:
Disk Drives: Hard disks, and the ancient floppy disks.
CD Drives: CD-R (writable) and CD-RW (rewritable).
Tape Drives: For archiving vast libraries of spells.
The monitor is your crystal ball, displaying text and graphical representations.
Resolution: The number of pixels (picture elements) per square inch. Higher resolution generally means sharper images. A common setting for a 15-inch monitor might be $640 \times 480$ pixels.
Dot Pitch: The space between pixels. Smaller dot pitch leads to a clearer display.
These devices allow your machine to converse with others across networks.
Modem: Uses phone lines (up to 56,000 bps).
DSL (Digital Subscriber Line): Faster than a regular modem, also uses phone lines.
Cable Modem: Uses TV cable lines, comparable speed to DSL.
Network Interface Card (NIC): Connects to a Local Area Network (LAN), with speeds like 10 Mbps (megabits per second).
Programs, or software, are the sets of instructions that tell the computer what to do. Without them, a computer is but an inert collection of parts. Since computers don't understand human tongues directly, we use programming languages.
Module 2: Understanding Programming Languages
This section explores the different dialects used to communicate our intentions to the machine.
The Spectrum of Languages
Programming languages form a hierarchy, from the raw language of the machine to more human-readable forms.
This is the native tongue of the CPU, a sequence of binary codes (0s and 1s) representing primitive instructions.
Directly Understood: The only language a computer truly understands without translation.
Tedious & Difficult: Writing in machine language is cumbersome and error-prone for humans. Example: 1101101010011010 might be an instruction to add two numbers.
Machine-Dependent: Specific to a particular computer hardware design.
Developed to make programming easier by using English-like abbreviations (mnemonics) for machine instructions.
Assembler: A special program that translates assembly language into machine code.
Example:ADDF3 R1, R2, R3 could be an assembly instruction for addition.
Still Low-Level: Closer to the hardware than high-level languages.
These languages are English-like and use familiar mathematical notations, making them easier to learn and use. C is a prime example.
Compiler/Interpreter: Translator programs (compilers or interpreters) convert high-level language source code into machine language. Compilers: Translate the entire program at once, creating an executable file. This can take time, but the resulting program runs quickly. C uses a compiler. Interpreters: Execute program statements directly, one by one. This avoids compilation delay but can result in slower execution. Python often uses a mix of compilation (to bytecode) and interpretation.
Example:area = 5 * 5 * 3.1415;
Source Code: The human-readable statements written by the programmer.
A pantheon of powerful languages exists, each with its strengths:
COBOL: For business applications.
FORTRAN: For formula translation in scientific and engineering fields.
Java: "Write once, run anywhere," used for enterprise apps, web servers, consumer devices. Developed by Sun (now Oracle).
Python: Versatile, object-oriented, popular in data science, web development, and education. Developed by Guido van Rossum.
C++: An object-oriented extension of C, developed by Bjarne Stroustrup.
C#: Microsoft's object-oriented language, often used for web and Windows development.
JavaScript: The scripting language of the web, adding interactivity to pages. NodeJS allows it to run server-side.
Swift: Apple's language for iOS and macOS apps.
R: Popular for statistical applications and data visualization.
And many more... (BASIC, Pascal, Ada, Visual Basic, Delphi)
Module 3: The C Programming Language
We now focus on the venerable C language.
Why Learn C?
Foundation for many other languages (C++, Java, C#).
Used in system programming, embedded systems, game development, and high-performance computing.
Offers a good understanding of how computers work at a deeper level.
(The slides mention "To describe the history of C," but don't provide it. We can add a placeholder or research this if desired.)
The C language was developed at Bell Labs by Dennis Ritchie in the early 1970s, evolving from an earlier language called B, which was created by Ken Thompson. It was developed alongside the UNIX operating system, and much of UNIX was rewritten in C.
Write: Create a source code file (e.g., my_program.c) using a text editor.
Compile: Use a C compiler (like GCC) to translate the source code into machine code, creating an executable file. gcc my_program.c -o my_program
Run: Execute the compiled program. ./my_program
A simple C program might look like this:
#include <stdio.h>
int main() {
// This is a comment
printf("Hello, World of C!\\n");
return 0;
}
#include <stdio.h>: Includes the standard input/output library.
int main() { ... }: The main function where execution begins.
printf(...): A function to print output to the console.
\\n: Represents a newline character.
return 0;: Indicates successful program termination.
Syntax Errors: Grammatical mistakes in the code that prevent compilation (e.g., missing semicolon). The compiler will usually point these out.
Runtime Errors: Errors that occur while the program is running (e.g., dividing by zero, trying to access invalid memory). These can crash your program.
Logic Errors: The program compiles and runs, but produces incorrect results because the underlying algorithm or reasoning is flawed. These are often the trickiest to find.
C Standard Library: A collection of pre-built functions and macros for common tasks (input/output, string manipulation, math operations, etc.). This helps avoid "reinventing the wheel." Accessed via #include directives (e.g., stdio.h, stdlib.h, math.h).
Open-Source Libraries: Vast collections of third-party code available for use, extending C's capabilities significantly.
Module 4: Data Hierarchy
Understanding how data is structured, from the smallest bit to vast databases.
Difficulty: Beginner
Time: 10 minutes
Impact: Medium
Focus: Data Concepts
Data Organization Exercise
Consider a student enrollment system. Identify examples of:
1. Bits (conceptual, e.g., a flag for 'is_enrolled')
2. Characters (e.g., a student's initial)
3. Fields (e.g., 'FirstName', 'StudentID', 'GPA')
4. Records (e.g., all information for one student)
5. Files (e.g., a 'students.csv' containing all student records)
6. Databases (e.g., a relational database managing tables of students, courses, and enrollments)
Reflect on how these levels build upon each other.
The fundamental unit of data, short for "binary digit." A bit can be either a $0$ or a $1$. They form the basis of the binary number system.
To make data more human-friendly, bits are grouped to represent characters:
* Decimal digits ($0–9$)
* Letters (A–Z, a–z)
* Special symbols (e.g., $, @, %, &, )
* Character Set:* The collection of characters a computer can represent. C traditionally uses ASCII (American Standard Code for Information Interchange) by default. Unicode is also supported for broader character representation, using 1 to 4 bytes per character.
A group of characters or bytes that conveys a specific meaning.
* Example: A person's name (a field of characters) or age (a field of digits).
A group of related fields.
* Example: An employee record might consist of fields like Employee ID, Name, Address, Hourly Pay Rate, etc.
A group of related records. Files can contain arbitrary data in various formats. Some operating systems see a file as just a sequence of bytes, with the application programmer defining its internal structure (like records). Files can be massive, holding gigabytes or terabytes of information.
A collection of data organized for easy access and manipulation.
* Relational Databases: A popular model where data is stored in tables. Tables consist of records (rows) and fields (columns).
* Example: A student database might have a table for students with fields like first_name, last_name, student_ID, major, GPA.
Refers to the enormous volume of data being generated globally. Big data applications deal with processing and analyzing these massive datasets, a rapidly growing field.
(The slides mention this but provide no details. We can elaborate based on common practices.)
Setting up Your Workshop
A typical C development environment includes:
Text Editor: To write your C source code (e.g., VS Code, Sublime Text, Vim, Emacs, or a full-fledged IDE).
C Compiler: To translate your source code into an executable program (e.g., GCC (GNU Compiler Collection) on Linux/macOS, MinGW for Windows, or Clang).
Debugger: A tool to help you find and fix errors in your code by stepping through it line by line (e.g., GDB (GNU Debugger)).
Build Tools (Optional for larger projects): Tools like make to automate the compilation process of projects with multiple source files.
Version Control System (Recommended): Tools like Git to track changes to your code and collaborate with others.