Chapter 230 min read
Introduction to C Programming & Your First Program
CC102: Computer Programming 1 — St. Cecilia's College–Cebu, Inc.
Released2025–2026
Core MottoDoing ordinary things extraordinarily well
CreatorsMichael John Bustamante
1. 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.
2. Core Building Blocks of C Programs
Before writing full programs, you need to understand the main structural elements 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.
3. 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.
4. How a C Program Runs: The Compilation Process
Understanding how source code (.c) converts into executable code (.exe).
The 4 Stages of C Compilation
1.
Preprocessing:Removes comments and expands `#include` header files.
2.
Compilation:Translates C source code into assembly language code.
3.
Assembly:Translates assembly code into machine binary object code (`.obj` / `.o`).
4.
Linking:Combines object files and system libraries into the final executable file (`.exe`).
5. 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.