Follow The New Tutorial updates on WhatsApp, Telegram or YouTube.

Escape Sequence in C Language

An escape sequence in C language is a sequence of characters that doesn’t represent itself when used inside string literal or character.

Generally, an escape sequence begins with a backslash ‘\’ followed by a character or characters.

It is translated into another character or a sequence of characters that may be difficult or impossible to represent directly.

It is composed of two or more characters starting with backslash \. For example: \n represents new line.

Escape sequences are used to format the output text and are not generally displayed on the screen.

List of Escape Sequences in C

Escape SequenceMeaning
\aAlarm or Beep
\bBackspace
\fForm Feed
\nNew Line
\rCarriage Return
\tTab (Horizontal)
\vVertical Tab
\\Backslash
\’Single Quote
\”Double Quote
\?Question Mark
\nnnoctal number
\xhhhexadecimal number
\0Null
List of Escape Sequences in C

Example

#include<stdio.h>    
int main(){    
     int number=50;  
    printf("You\nare\nlearning\n\'c\' language\n\"Do you know C language\"");     
return 0;  
}    
Escape Sequence in C Language Example – Output

Example – 2

#include <stdio.h>
int main ()
{
printf("\n horizontal tab escape sequence tutorial");
printf(" \n 34543 \t 345435 ");
printf(" \n 123 \t 678 ");
return 0;
}
Horizontal Tab Escape Sequence in C Language Example – Output