Day 1 Progress
0%
Day 1  ·  1 Hour

Intro to C Programming

From zero to your first working program — understand how C thinks, and why it matters.

0–10 min · What is C?
10–25 min · Structure & Syntax
25–45 min · Variables & I/O
45–60 min · Practice & Quiz
1

What is C? Why Learn It?

0 – 10 min

C is a general-purpose, compiled, low-level language created by Dennis Ritchie at Bell Labs in 1972. It was designed to write operating systems — the Unix kernel was rewritten in C. Today, C still runs the world:

  • 🐧 Linux kernel — millions of lines of C
  • 🎮 Game engines, embedded systems, microcontrollers
  • 🐍 Python, Ruby, PHP interpreters are built in C
  • ⚙️ Databases (SQLite, PostgreSQL) are written in C

Why start with C? Because C teaches you how computers actually work — memory, pointers, bits. Every other language makes more sense after C. It forces you to think clearly.

💡 Key mindset: In C, you manage memory. The language trusts you completely — giving you power and responsibility. No garbage collector. No safety net. This is what makes C both demanding and deeply educational.
2

How C Works: Compile → Run

10 – 18 min

C is a compiled language. You write source code → the compiler translates it to machine code → your CPU runs it directly. This makes C extremely fast.

  • Step 1 — Write code in a .c file
  • Step 2 — Compile with gcc hello.c -o hello
  • Step 3 — Run with ./hello
terminal
bash
# Compile your source file
gcc hello.c -o hello

# Run the compiled program
./hello

# Output:
Hello, World!
3

Your First C Program

18 – 28 min
hello.c
C
#include <stdio.h>   // Include standard I/O library

int main() {           // main() is where execution starts
    printf("Hello, World!\n");  // Print to screen
    return 0;           // 0 = success
}
  • #include <stdio.h> — imports the Standard Input/Output library. You need this for printf and scanf.
  • int main() — every C program has exactly one main function. This is the entry point.
  • printf() — prints formatted text. \n is a newline character (moves cursor to next line).
  • return 0; — tells the OS the program finished successfully. Non-zero means error.
  • { } — curly braces define a block of code. Everything inside belongs to that block.
💡 Every statement ends with a semicolon ; — forgetting it is the #1 beginner mistake. The compiler will throw an error. Think of it like a period at the end of a sentence.
mid-lesson checkpoint
4

Variables & Data Types

28 – 42 min

In C, you must declare the type of every variable before using it. The type tells the computer how much memory to allocate and how to interpret the bits stored at that location.

TypeSizeRange / UseExample
int4 bytesWhole numbers (±2 billion)int age = 25;
float4 bytesDecimal numbers (~7 digits)float pi = 3.14f;
double8 bytesPrecise decimals (~15 digits)double x = 3.14159;
char1 byteSingle character / small intchar c = 'A';
variables.c
C
#include <stdio.h>

int main() {
    int    age    = 20;
    float  gpa    = 3.85f;
    char   grade  = 'A';
    double salary = 52000.50;

    printf("Age: %d\n",     age);    // %d = integer
    printf("GPA: %.2f\n",   gpa);    // %.2f = 2 decimal places
    printf("Grade: %c\n",   grade);  // %c = character
    printf("Salary: %.2f\n", salary); // %lf for double in scanf

    return 0;
}
💡 Format specifiers tell printf how to display a value:
%d → int    %f → float/double    %c → char    %s → string    %ld → long
5

Getting Input from the User

42 – 52 min

scanf() reads input from the keyboard. Notice the & before variable names — this gives scanf the address of the variable in memory, so it knows exactly where to store the value you type. (This is your first glimpse at pointers — for now, just always remember the &.)

input.c
C
#include <stdio.h>

int main() {
    int  age;
    char name[50];   // Array of 50 chars = a string

    printf("Enter your name: ");
    scanf("%s", name);    // No & needed for arrays

    printf("Enter your age: ");
    scanf("%d", &age);    // & gives the address of age

    printf("Hello, %s! You are %d years old.\n", name, age);

    return 0;
}
6

Arithmetic & Expressions

52 – 58 min
OperatorMeaningExampleResult
+Add5 + 38
-Subtract10 - 46
*Multiply6 * 742
/Divide9 / 24 (integer!)
%Modulus (remainder)9 % 21
calculator.c
C
#include <stdio.h>

int main() {
    int a = 9, b = 2;

    printf("%d + %d = %d\n", a, b, a + b);
    printf("%d / %d = %d\n", a, b, a / b);   // = 4, not 4.5!
    printf("%d %% %d = %d\n", a, b, a % b);  // = 1

    // For real division, cast to float:
    printf("%.2f\n", (float)a / b);  // = 4.50

    return 0;
}
⚠️ Integer division truncates! 9 / 2 gives 4, not 4.5. The decimal is simply dropped, not rounded. Cast to (float) or (double) when you need the full decimal result.
practice & quiz
Q

Quick Quiz — Test Yourself

58 – 60 min
Question 1 of 4

What does return 0; in main() mean?

Question 2 of 4

What is the output of: printf("%d", 7 / 2); ?

Question 3 of 4

Which format specifier is used to print a float?

Question 4 of 4

Why do we write &age inside scanf()?

Lesson Checklist

  • I understand what C is and why it matters
  • I know the compile → run workflow with gcc
  • I can read and write a Hello World program
  • I understand #include, main(), printf, and return 0
  • I know the 4 basic data types: int, float, double, char
  • I can use format specifiers (%d, %f, %c, %s)
  • I can read user input with scanf()
  • I understand integer division truncation
  • I completed the quiz