DAY 02 : ESCAPE SEQUENCES AND COMMENTS
#100DaysCodeChallenge

The escape sequences and comments are the most predominant building blocks of a C Program. Hence, a good programmer is advised to well verse his/herself in escape sequences and comments.
ESCAPE SEQUENCES :
The escape sequences in a C program plays a pivotal role. They are widely defined as the non-printing control characters. They usually begin with a backslash (\).
For example, consider the code given below:
#include <stdio.h>
int main()
{
printf("\nWelcome");
printf("\nHi");
return 0;
}
In the above code, we have used \n, which is an escape sequence. It's usage is printing characters in a new line.
Like \n, there are many escape sequences available in C language which comes to use when mentioned in the code. The other escape sequences are
\t = tab
\b = backspace
\n = new line
For printing question marks, backslash, single quotes and double quotes on the screen, we have another new set of escape sequences as follows :
\? = question mark
\\ = backslash
\' = single quote
\" = double quote
COMMENTS :
Comments are merely internal program documentation. It is widely written for the reader to understand the code clearly. It is deemed to be a good programming habit to comment at the top of the program defining the usage and purpose of the program. Comments usually elaborates the process of the code in brief and also deemed to be the way of explaining what a program does. The compiler, while compiling ignores all the comments mentioned in the code. Comments are in common known as non-executable statements. We have the liberty to use comments anywhere in the code, either at the beginning or at the end or in between the code too.
Basically, comments are divided into two types. They are
1. Line comments
2. Block comments
LINE COMMENTS :
Line comments are also called as single-line comments. Only one line comments can be represented using line comments. It is represented using the symbol //.
For example, consider the code given below:
#include <stdio.h>
int main()
{
printf("\nWelcome");
//prints the message
return 0; //returns a value 0 to the operating system
}
In the above code, we can clearly see that line comments can be used anywhere in the code. It does not require to be specifically ended as the end of the line on its own ends the line automatically.
BLOCK COMMENTS :
Block comments are also known as multi-line comments. Using block comments, we can add multi-line comments. It specifically needs an ending symbol to represent the ending of the comment since it has many lines in it. It is represented using two symbols. Those symbols are shown below :
/* = for beginning block comment
*/ = for ending block comment
For example, consider the code given below:
/*To print Welcome on the screen
Language : C */
#include <stdio.h>
int main()
{
/*Prints the message.
Returns a value to the operating system.*/
printf("\nWelcome");
return 0;
}
In the above code, we can clearly see that block comments can be used anywhere in the code either in the middle or at the start of the code to describe the perspective of the code in short.
Since, comments are not executed by the compiler during the process of compiling, it does not affect two aspects:
>> Execution speed
>> Size of compiled program
Comments used in the code aid other users in understanding the code clearly and plays a pivotal role in debugging and testing.
In this second day of #100DaysCodeChallenge, we have discussed about escape sequences and comments in C Programming Language. The definition, explanation, usage and purpose of escape sequences and comments are thereby discussed.
Have a great day friends!!
Thank you!!
About the Creator
Preethi Siva
Writing is not my hobby.........
It comes when my heart is connected to my soul and says to write!!!


Comments (1)
On the second day of the #100DaysCodeChallenge, we spoke about C programming language escape sequences and comments. https://geometrydashworld.net