Escape Sequence in C | Escape Sequences in C with examples

Escape Sequence in C is a sequence of character which is used for formatting the output in a structured way. But it did not get displayed on the screen while printing the output. In an escape sequence, a character denotes a different meaning from its actual meaning and undergoes a change from its normal form.

It is a sequence of characters that doesn’t represent itself when used inside a character or a string but has its own specific function.

Escape sequences are special character denoted by a backslash (\) and a character after it. E.g. \t is an escape sequence because the \ causes an ‘escape’ from the normal way the characters are interpreted. In the example given above, it is interpreted as the ‘tab’ character and not as character ‘t’. Escape sequences can be used in both character and string constants.


Some of the common escape sequence characters are:


Escape Sequence

Meaning

\a

Bell (beep)

\b

Backspace

\f

Form feed                  

\n

New Line

\t

Tab

\r

Return (Enter key)

\0

Null character

\\

Backslash

\’

single Quotation Mark

\”

Double Quotation Mark



Programming Example:

Program to calculate simple interest...




Output:






Post a Comment

0 Comments