Escape Sequence

Escape Sequence:

They are used especially to perform some special operations like going to a new line, providing a horizontal tab, vertical tab, etc.


These characters followed by a backslash().
The following is a list of escape sequences.

Sr.no Escape Sequence Meaning
1.\nNewline
2.\tHorizontal tab
3.\vVertical tab
4.\bBackspace
5.\rCarriage return
6.\fForm feed
7.\aAudible alert(bell)
8.\\Backslash
9.\?Question mark
10\’Single quote
11\”Double quote
12\eescape character
13\xhhHexadecimal number
14\nnnOctal number
15\oNull character

Here is the Explanation for the following character :

  1. \n ( Newline): We use this type of character for moving the cursor to the new line
  2. \t (Horizontal tab): We use this type of character for moving the cursor leaving a couple of space
  3. \v (Vertical tab)
  4. \b (Backspace)
  5. \r (Carriage return): We use this type of character to locate the cursor to the start of the current line.
  6. \f (Form feed page break)
  7. \a (Audible alert(bell)): We use this type of character to produce beep type of audible bell so that the user can get the indication about the execution of the program
  8. \\ (Backslash): We use this type of character to display the backslash character
  9. \? (Question mark) : We use this type of character to display the question mark?
  10. \’ (Single quote): We use this type of character for displaying a single quote in the text
  11. \” (Double quote): We use this type of character for displaying the double quote in the text
  12. \e (the escape character)
  13. \xhh (Hexadecimal number): We use this type of character for displaying Hexadecimal number
  14. \nnn (Octal number): We use this type of character for displaying Octal number
  15. \o (Null character): We use this type of character for termination of the string

1.For Example of the new line :

#include<stdio.h> 
int main() 
{ 
 
printf("Welcome\n"); 
printf("to\n"); 
printf("Fem-code\n"); 
printf("Tutorials\n"); 
return 0; 
} 
OUTPUT:
Welcome 
to
Fem-code
Tutorials

2.For Example Of \a (Audible alert) :

#include<stdio.h> 
#include<conio.h>
void main()
{ 
    printf("My name is : A/B/H/I/S/H/E/K");
    getch(); 
} 

OUTPUT:
My name is : ABHISHEK

3.For Example Of \t(Horizontal tab) :

#include<stdio.h> 
#include<conio.h>
void main()
{ 
    printf("My name is : A/tB/tH/tI/tS/tH/tE/tK");
    getch(); 
} 

OUTPUT:
My name is : A  B  H  I  S  H  E  K

Translate »