Control line breaks, tabs, and special characters using backslash escape codes.
1. The Hook Have you ever tried typing a document without ever hitting the Enter key or Spacebar? All your words would smash together into one unreadable block of text!
How do we tell printf to break lines or create tab columns?
2. Real World Story When typing on a typewriter, there was a physical lever called Carriage Return that moved the paper roller to the next line.
In C, we use Escape Sequences starting with a backslash \ to perform formatting commands!
3. Problem
How do you print quotation marks inside text or move to a new line inside a single printf?
4. Concept: Escape Sequence Lookup Table
| Escape Code | Name | What It Does | Example |
| :--- | :--- | :--- | :--- |
| \n | Newline | Moves cursor to start of next line | printf("A\nB"); -> A on line 1, B on line 2 |
| \t | Tab Space | Inserts 4-8 tab spaces | printf("Name:\tAmit"); |
| \\" | Double Quote | Prints literal double quote " | printf(\"Hello \\"BEU\\"\"); -> Hello "BEU" |
| \\ | Backslash | Prints literal backslash \ | printf("C:\\Files"); |
5. Mental Model - `\n` = Hitting Enter key on keyboard. - `\t` = Hitting Tab key on keyboard.
6. Code Example
#include <stdio.h>int main() { printf("Subject\t\tMarks\n"); printf("---------------------\n"); printf("Physics\t\t95\n"); printf("Maths\t\t98\n"); return 0; } ```