coderz.py

Keep Coding Keep Cheering!

Comments in C

Matrix multiplication

Comments in C are an explanation or description of the source code of the program. It helps a developer explain the logic of the code and improves program readability.  These comments are not executed by the compiler rather ignored by it.

Type of comments:

 There are two types of comments in the C language.

  • Single-Line Comments
  • Multi-Line Comments

Single line Comment:

  • Single line comments are represented by // double slash.
  • It denotes only a single line that gets commented.
  • Syntax:
//code to be commented

Multi-line Comment:

  • Multi-line comments are represented by /*……*/ i.e., start with forwarding slash and asterisk (/*) and end with asterisk and forward-slash (*/)
  • It denotes multiple lines that get commented.
  • Syntax:
/*  
code 
.....
.....
.....
to be commented 
*/  
Example:
#include<stdio.h>    
int main(){    
    /*Start of main()
      Program to print hello coderzpy
      Multi-Line Comment*/  
    printf("Hello Coderzpy !"); 
   
    return 0;  
   //end of main()
}    
OUTPUT: Hello Coderzpy !

In the above code /*printing information Multi-Line Comment*/ is the multi line comment whearas, //end of main() is single line comment.

Need for Comments :

  • A person reading a large code will be confused if comments are not present about the details of the program.
  • A comment makes a code more readable by providing more description.
  • They can include a description of an algorithm to make code coherent.
  • Comments can be helpful for our code if it is reused after a long interval.

note: also read about  Variables & Constants in C & Precedence of Operators in C.

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Leave a Comment

Your email address will not be published. Required fields are marked *

Advertisement