The escape sequence in C represents nongraphic characters (nongraphic characters are those characters that cannot be typed directly from the keyboard, for instance, backspace, tabs, carriage return, etc). An escape sequence is represented by a backslash(\) followed by one or more characters. Escape sequences are beneficial to programmers who want to format the output.
List of Escape Sequence in C:
Escape Sequence | Meaning |
---|---|
\a | Alarm or Beep |
\b | Backspace |
\f | Form Feed |
\n | New Line |
\r | Carriage Return |
\t | Tab (Horizontal) |
\v | Vertical Tab |
\\ | Backslash |
\’ | Single Quote |
\” | Double Quote |
\? | Question Mark |
\nnn | octal number |
\xhh | hexadecimal number |
\0 | Null |
Example:
#include <stdio.h>
int main() {
// Write C code here
printf("Hello world\nCoderzpy\tC language");
printf("\"Have a great day!\"");
return 0;
}
Output:
Hello world
Coderzpy C language
“Have a great day!”
Note: also read about Comments in C & Format specifiers in C.
Follow Me
If you like my post please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Leave a Comment