C Single Line Comment

Single Line Comment are non-executable code used to provide documentation to programmer. Single Line Comment is used to  comment out just Single Line in the Code. It is used to provide One Liner Description of line.

Some Important Points :-
  1. Single Line Comment Can be Placed Anywhere
  2. Single Line Comment Starts with ‘//’
  3. Any Symbols written after ‘//’ are ignored by Compiler
  4. Comment cannot hide statements written before ‘//’ and On the Successive new line

 Example :-

#include<stdio.h>

void main()
{

printf("Hello"); //Single Line Comment

printf("By");

}


Which Part is Ignored by Compiler ? [Shown by Asterisk]:-

#include<stdio.h>
void main()
{
printf("Hello"); // ********** Until Line Ends *****

printf("By");

}

Explanation :
  1. In the above code we have included Single Line Comment. Single Line Comment can be used anywhere in the code.
  2. Single Line Comment ignores the complete line from the position where it has been written.Therefor Single line comment is written usually after termination of statement.
  3. For Multiple Line Comment we have another approach.Learn More on Difference between Single Line and Multiple Line Comment.
C Single Line Comment  C Single Line Comment Reviewed by ANAND PANDEY on 7:19:00 AM Rating: 5

No comments:

Created By Anand Pandey. Powered by Blogger.