Escape Sequence In C Language

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

In the C programming language, an escape sequence is a combination of characters that represents a special character or symbol that is not represented by a single character. An escape sequence begins with a backslash \ followed by another character.

Here are some common escape sequences used in C:

  • \n : newline
  • \r : carriage return
  • \t : horizontal tab
  • \v : vertical tab
  • \b : backspace
  • \f : form feed
  • \\ : backslash
  • \' : single quote
  • \" : double quote

For example, the following code will print "Hello, World!" on two lines:

Copy code

printf("Hello,\nWorld!");

This will output:

Copy code

Hello, World!

Another example is to use a single quote or double quote inside a string, you can use escape sequence to specify them.

Copy code

printf("This string contains a single quote: '"); printf("This string contains a double quote: \"");

This will output:

Copy code

This string contains a single quote: ' This string contains a double quote: "

Escape sequences are also used to represent non-printable characters and special characters that are not present on the keyboard.

It's important to note that some escape sequences, such as \n and \t, are interpreted by the compiler and affect the layout of the output, while others, such as \\ and \", are used to represent special characters within strings.

3. Input Output In C

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?