C Tutorial
C is one of the oldest and most influential programming languages still in use. Operating systems like Windows, Linux and macOS, the software inside appliances and cars, and even the Python language itself are built with C. Learning C teaches you how computers really work: memory, addresses and bytes.
This free course has 16 lessons. Every example is a complete program shown with its exact output, so you can study even without a computer. Each lesson ends with a Taglish summary and a quick quiz.
How to run the examples
- On a computer: install a C compiler, such as GCC through Code::Blocks, Dev-C++ or MSYS2 on Windows, or Xcode Command Line Tools on a Mac. Lesson 2 shows how.
- On a phone: use an online C compiler, or an Android app that compiles C.
Before you start
No experience is needed, but C expects you to be careful: it does exactly what you say, even when that's a mistake. That's what makes it a great teacher. Many college Computer Science and Engineering programs start with C.
What you'll be able to do
- Write, compile and run C programs
- Read input with
scanfand format output withprintf - Use decisions, loops, arrays and strings
- Organize code into functions
- Understand pointers and memory, the heart of C
- Store records with structs and save them to files
All lessons
Getting Started
- Introduction to C ProgrammingWhat the C language is, its history, where it's used today, why it's worth learning, and the parts of a first C program.
- Getting Started with C — Compilers and Your First ProgramInstall a C compiler (GCC with Code::Blocks or MSYS2, or Clang on Mac), compile and run a program from the command line, and read compiler errors and warnings.
- C Output with printf and Format SpecifiersPrint text, integers, decimals and characters with printf, use format specifiers like %d, %f, %.2f, %c and %s, set field widths, and write comments.
Basics
- C Variables, Data Types and ConstantsDeclare variables in C with int, float, double and char, understand sizes with sizeof, convert types with casting, and create constants with const and #define.
- C OperatorsArithmetic, assignment, increment and decrement, comparison and logical operators in C, plus the ternary operator and how C treats true and false as numbers.
- C User Input with scanf and fgetsRead numbers, characters and words with scanf and the & operator, read full lines with fgets, check scanf's return value, and avoid common input bugs.
Control Flow
- C if, else and switchMake decisions in C with if, else if, else and switch-case, avoid the dangling-else and missing-break traps, and build a grade descriptor and menu.
- C Loops — while, do-while and forRepeat code in C with while, do-while and for loops, use break and continue, and build sums, countdowns, multiplication tables and patterns with nested loops.
Arrays & Functions
- C Arrays and 2D ArraysStore many values in C arrays, loop through them, find the sum, average, highest and lowest, sort with bubble sort, and use 2D arrays for tables.
- C Strings — char Arrays and string.hHow C stores text in char arrays ending with '\0', and how to use strlen, strcpy, strcat, strcmp, toupper and fgets safely.
- C FunctionsWrite your own C functions with parameters and return values, declare prototypes, pass arrays to functions, understand scope and static variables, and use recursion.
Memory
- C Pointers ExplainedUnderstand memory addresses, the & and * operators, pointer variables, passing pointers to functions to change variables, pointers and arrays, and NULL.
- C Structures (struct) and typedefGroup related data into a struct, create arrays of structs, use typedef for cleaner names, access members with . and ->, and pass structs to functions.
- C Dynamic Memory — malloc, calloc, realloc and freeAllocate memory while the program runs with malloc and calloc, grow it with realloc, release it with free, and avoid memory leaks and dangling pointers.
- C File Handling — fopen, fprintf, fscanf and fcloseSave and load data with files in C — open files with fopen modes, write with fprintf and fputs, read with fgets and fscanf, check for errors and close files.
- C Final Project — Student Records with Structs and FilesBuild a menu-driven student record program in C using structs, arrays, functions, pointers, input validation and file saving and loading.