Skip to main content

Escape Sequences

 Sometimes, it is required to use newline, tab, quotation mark etc. in the program which  either  cannot  be  typed  or  has  special  meaning  in  C  programming.  In  such  cases, escape sequence are used. For that incident \n is used for newline. The backslash “\” causes escape from the standard way the characters are interpreted by the compiler.


This escape sequences are only used in printing statements like printf for example: 

printf(“\n Hello \t World!”). 

Table of Escape Sequences:

Escape
Character
\b
Backspace
\f
Form feed
\n
Newline
\r
Return
\t
Horizontal tab
\v
Vertical tab
\\
Backslash
\’
Single quotation mark
\*
Double quotation mark
\?
Question mark
\0
Null character

Examples created on escape sequence:

#include <stdio.h>
void main(){
printf (“\nHello\nWorld!”);
}
#include<stdio.h>
void main ( ){ 
Comment
printf (“Hello\tWorld!”);
}
#include<stdio.h>
void main(){
printf(“Hello World” \n);
}
o/p: 
Hello
World
O/p: Hello        World!
O/p:  Error
Note: Sequence escape always in between “ double quote”

Note: to print sequence escapes give \\

#include <stdio.h>
void main(){
printf (“Hello \\n World!”);
}
#include<stdio.h>
void main ( ){ 
printf (“Hello \\t World!”);
}
#include<stdio.h>
void main(){
printf(“Hello World” \\n);
}
o/p: Hello \n World
O/p: Hello \t World!
O/p:  Error
Note: Sequence escape always in between “ double quote”

Remaining sequence escape please try yourself.























Comments

  1. Best eCOGRA Sportsbook Review & Welcome Bonus 2021 - CA
    Looking for www.jtmhub.com an eCOGRA Sportsbook 바카라 사이트 Bonus? At this eCOGRA Sportsbook review, worrione.com we're talking about a variety of ECCOGRA sportsbook 바카라 사이트 promotions. deccasino

    ReplyDelete

Post a Comment

Popular posts from this blog

Comments in C

  Comment is the code which is not executable means compiler will not compile the comments and that’s why comments are not visible on output screen. Two types of Commenting: Type 1:  double slash ‘ // ’ method the whole statement after double slash is not executed by compiler Example: try to run below code its output will be blank screen #include <stdio.h> void main(){ // printf (“Hello World!”); } #include<stdio.h> void main ( ){ //Comments // Comment printf (“Hello World!”);//abc } #include<stdio.h> //Comments void main(){ //Comments printf(“Hello World”); } o/p:  blank screen O/p:  Hello World! O/p:  Hello World In this way you can give multiple comments anywhere in the program but double slash is used to  comment only single line for commenting multiple lines use type 2.  Type 2:  For multiline commenting or for commenting a whole paragraph from the program we have  to add /* at the start of comment and */ at the end of comment as shown in examples: #include <s

Why should I learn Computer language (Programming)? And why C language good for beginners?

1. Software is the spirit  ( आत्मा )  of hardware . 2. Just by joining some hardware (Electronics  Components) we can’t make our  Computers, Laptops, Mobiles, Tablets, etc. so programming is essential to make this hardware functional. 3. Program instructs and controls the hardware and C is the very basic language to start. 1. By learning a computer language you'll able to build your own software, OS, Virus, Antivirus. For example, WhatsApp, Hike, Calculator,  Media  Player, Facebook, Twitter. 5. After learning the C language you'll be able to build your own computer applications. 6. C language Helps to learn more advanced languages like Java, Dot Net, MATLAB. because this all language depends upon C language. 7. It is good for starters because it is just like the English language and easy to understand.

New trends and advantages of C language.

1. You can program the ROBOTS and  Automatic Running Machines  using C language. click here for more information.  2. For building more advanced  software or  Games you need to  learn more advanced languages like  Visual  Basic,  .NET, JAVA, ANDROID programming which is based on C.  3. To build a website you need only HTML and you can make your own website but for making it more advance you need to learn more web designing languages like CSS, JavaScript, Ajax, PHP and this all languages are very easy to learn if you have some basic knowledge about C. 4. After learning C you will be able to make your own software like Calculator, Games, Embedded Softwares, Compilers.