Comments And Escape Sequence
What’s the comment? What is the
purpose of using comments in the program?
Ans: The comment is to make a note for yourself or someone else while
writing the source code.
The purpose of using comments in
the program
1. To make the purpose of the program
easier to understand.
2. Used to write descriptions of
programs.
3. To explain what a line of the program
means.
There are two types of comments
1. Single line comment
2. Multiple line comment
Single line comment:
1. Single-line comment anywhere in the
program can be used.
2. Single-line comment starts with (//).
3. After compiling something with (//)
the compiler avoids it.
Example:
Multiple Line Comment:
1. Multiple line comments can be used anywhere
in the program.
2. Multiple line comment starts with (/*).
3. Multiple line comments end with (*/).
Remember:
1. Single-line comment was created by
C++. Its use in C programming is
technically invalid, but some compilers will accept it.
2. In C, you can’t have one comment
within another comment.
Example:
/*This is a comment
/*This is another comment
Inside comment*/
A syntax error*/
Escape
sequence
The C program uses some Backslash Character which acts as an output function.
1. Usually a character is used after
giving Backslash (\).
Character
Escape Sequence |
Meaning |
\a |
(Alert)Bell |
\b |
Back
Space |
\f |
Form
Feed |
\n |
New
Line |
\r |
Carriage
Return |
\v |
Vertical
Tab |
\0 |
Null
Character |
\’ |
Single
Quote |
\” |
Double
Quote |
\\ |
Backslash |
\? |
Question
mark |
\t |
Horizontal
Tab |
0 Comments