What is Escape Sequence in C Programming

LAST READ: APR 15 2024 | Author: JANET

Escape Sequence in C

Escape Sequence in C

In C programming Escape Sequences are pre-defined groups of symbols and characters that have special meanings to the compiler and when they execute in the code, perform some specific task. In C programming Escape Sequences usually starts with \ symbol and, followed by some characters or numbers. For example, \n is used for newline in the program.

Most of the modern programming languages also have escape sequences, they are all inspired by the features of the C programming language.

Important Points about Escape Sequences

  • An escape sequence always starts with the \ symbol.
  • The escape sequences are represented by \ symbol followed by any character or symbol.
  • Each escape sequence has its special meanings and they cannot be used in general writing in c programming.
  • Escape sequences can be used for only their special purpose in C programming.
  • For example, \n is an escape sequence and it is used for a new line.
  • In the below table, we have listed all escape sequences with their special meanings.

List of Escape Sequence in C

  • \b  (Backspace)
  • \f  (Form feed)
  • \n (Newline)
  • \r (Carriage return)
  • \t (Horizontal tab)
  • \" (Double quote)
  • \' (Single quote)
  • \\ (Backslash)
  • \v (Vertical tab)
  • \a (Alert or bell)
  • \? (Question mark)
  • \N (Octal constant (N is an octal constant))
  • \XN (Hexadecimal constant (N – hex.dcml cnst))
  • \0 (Null character)

Top Points

  • The Escape sequence is a reserved set of sequences.
  • The meaning of escape sequences is predefined by the c library, which can not be changed.
  • Escape sequences cannot be used as a regular statement in c programming.



 int main()


     int m=10, n=2, res;


     printf("Sum = %d\n",res); // we have used \n for new line


     printf("\"Subtraction = %d\n\"",res); // to print " we have used \"

     return 0;



Sum = 12

"Subtraction = 8"

Note: Like the above example, you can use escape sequences as where they are required in C programming.

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

LifeStyle & Fun

© 2024 GDATAMART.COM (All Rights Reserved)