Comments in C language | types of Comments delimiter with examples
Comments in C language | types of Comments delimiter with examples
What is a Comments in C language?
Comments are used to describe or indicate or comments the large block of text or fragments of code or the nearest codes and syntaxes for programmer (comment is readable explanations of code for programmers). Comments have words or single sentence or single paragraph but, it does not change the meaning of program or nearest code. Compiler treats like meaningless or Blank.
Comment provides clarity of the C program source code which allow the programmer to understand the intend of lines of codes.
Comments are very important because comments help the programmers to understand if debug in found in program which contains thousand of lines of codes.
In C language, There are two syntaxes which are use to give the comments before or after code or block of texts.
Comments using Preprocessor directives:
it is typically use to make easy the sources of programs and also make easy to compile in different level of execution environments. Directives of source codes file declare the preprocessor to specific action.
Like: preprocessor can be change the place of Tokens present in the Text, Insert the contents of other files into the source file. Statements of Preprocessor are use the same set of characters as source file statements, same as the execution and also recognizes negative characters values and escape sequence which are not supported.
The preprocessor recognizes the some following directives which are given below:
Number sign(#) must be first before characters without white-space in line which contains directive. Only white-space character can exist between number sign and first character of directive. But, some directive includes the arguments or values. Any block of text which follow directive (excepts argument and variable that are part of the directive) and followed by single-line comment delimiter (//) and multi-line comment delimiter (/* */).
- #define
- #elif
- #else
- #endif
- #error
- #if
- #ifdef
- #ifndef
- #import
- #include
- #line
- #pragma
- #undef
- #using
#if 0
/* You can start comments from here */
/* this delimiter is use for multiple line */
//this delimiter is use for single line
#endif
There are two types of Comments in C language:
/* */ delimiter comments for multiple-line:
These comments starts with a forward slash and asterisk (/*) and also end with same asterisk and slash (*/). You may know that it is executed as blank( means ignored by C compiler).
/* delimiter is use to comment for multiple-line.
Means you can use this delimiter for paragraph,
Large or long block of text with multi-line */
/* printf("%d is a real number", num);printf("%d is not a real number", num); */
// delimiter comments for single-line:
//this delimiter is use for single-line comments.
//it's mean that only use single line or words or
// block of text but arranged in single-line without press 'Enter key'.
//printf("%d is a real number", num);
Post a Comment
0 Comments
Thanks For Reading our Blog we are working to spreed knowledge around the globe .
Regards : Khan Developer