Nearby lessons
21 of 124C - Escape Sequences
Escape Sequences is one of the foundational topics in C programming. This lesson explains Common Escape Sequences and Program: escape sequences in action with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
Common Escape Sequences
| Escape | Meaning |
|---|---|
| \n | New line — move to the next line |
| \t | Tab — move to the next tab stop |
| \b | Backspace |
| \" | Print a double quote |
| \\ | Print a backslash |
| %% | Print a percent sign |
In simple words: an escape sequence is a secret code inside the quotes that starts with \ — \n means new line, \t means tab. The code is not printed; its effect is.
Program: escape sequences in action
Example02
📝 Key Takeaways
- printf() outputs; scanf() inputs (from stdio.h).
- Format specifiers: %d int, %f float, %.2f two decimals, %c char, %s string.
- Escape sequences: \n new line, \t tab, \\ backslash, %% percent.
- scanf needs & before variables (except strings).
- getchar()/putchar() handle one character.
- getch/getche are Windows-only; prefer standard getchar.
🧠 Test Your Knowledge
2 QuestionsProgress: 0 / 2