Escape sequence are useful for formatting the Input and Output. All Escape sequences are start from Back slash " \" followed by a character. The " \n " new line is most commonly used in printing statement.
Escape Sequence with ASCII Value
| Character | Escape Sequences | ASCII Value |
| Null | \0 | 0 |
| Bell (alert) | \a | 7 |
| Backspase | \b | 8 |
| Horizontal tab | \t | 9 |
| New line | \n | 10 |
| Vertical tab | \v | 11 |
| Formfeed | \f | 12 |
| Carriage return | \r | 13 |
| Double quote | \" | 34 |
| Single quote | \' | 39 |
| Question mark | \? | 63 |
| Backslash | \\ | 92 |
| Octal number | \ooo | any |
| Hexadecimal number |
\xhh | any |
Octal Number:
Example: \7, \007, \786
Hexadecimal Number:
Example: \x5, \x57, \x7f
Program to display ASCII value
#include <stdio.h>
int main(){
printf("Null=%d\n",'\0');
printf("Bell (alert)=%d\n",'\a');
printf("Backspase=%d\n",'\b');
printf("Horizontal tab=%d\n",'\t');
printf("New line=%d\n",'\n');
printf("Vertical tab=%d\n",'\v');
printf("Formfeed=%d\n",'\f');
printf("Carriage return=%d\n",'\r');
printf("Double quote=%d\n",'\"');
printf("Single quote=%d\n",'\'');
printf("Question mark=%d\n",'\?');
printf("Backslash=%d\n",'\\');
return 0;
}
Output
Null=0Bell (alert)=7
Backspase=8
Horizontal tab=9
New line=10
Vertical tab=11
Formfeed=12
Carriage return=13
Double quote=34
Single quote=39
Question mark=63
Backslash=92
Example program to print Escape sequences and percentage symbol.
#include <stdio.h>
int main(){
printf("\aC Program\n");
printf("New line =\\n\n");
printf("Percentage symbol=%%");
return 0;
}




