MyWhiteBoard TrainingHome

PRACTICAL C COURSE

C Programming from First Steps to Systems Thinking

Learn how C programs use data, functions, memory, and the standard library. Every topic includes a runnable example for Open Editor.

What you will learn

  • Write, compile, and run clear C programs using the standard library.
  • Control program flow with decisions, loops, functions, and arrays.
  • Use pointers and dynamic memory with explicit ownership and cleanup.
  • Build practical programs that read input, process data, and report errors.

Practice method: type each example into Open Editor, predict its output, run it, then alter one input or condition and run it again.

1. Core language basics

Program shape

A C program starts in main. Include stdio.h when using printf, and return a status code from main.

#include <stdio.h>

int main(void)
{
    printf("Hello, C!\n");
    return 0;
}

Values and flow

Choose a type that describes the value, initialize variables, and make conditions easy to read.

for (int number = 1; number <= 5; ++number)
{
    if (number % 2 == 0)
    {
        printf("%d is even\n", number);
    }
}

2. Functions and arrays

One function, one job

Functions make a program testable and reduce repeated logic. Give every function a declaration with clear parameter and return types.

int square(int value)
{
    return value * value;
}

Array bounds matter

C does not check array bounds automatically. Track the length and never index outside the valid range.

int scores[] = {72, 95, 81};
size_t count = sizeof scores / sizeof scores[0];

3. Pointers and memory

A pointer holds an address. Dynamic memory from malloc must be checked and released exactly once with free.

int *score = malloc(sizeof *score);
if (score != NULL)
{
    *score = 100;
    free(score);
}

Memory rule: initialize pointers, check allocation results, keep ownership obvious, and set freed pointers to NULL when they remain in scope.

Before you move on

  • I can explain the structure of a C program.
  • I can use loops and functions to avoid repetition.
  • I know the difference between an array and a pointer.
  • I check every dynamic allocation before use.
  • I free memory I allocate.
  • I can read compiler warnings and fix the first one.