Saturday, December 23, 2017

What is a comment in c language


A program requires you to be careful and articulate. You need to make sure that your program is both executable and aesthetically pleasing. 
      A messy program does not only cause errors, but it also results in confusion. For example, if you have been working on a particular program for so long, you may tend to forget some details.
      Thus, taking down notes is necessary. The comments in programs seem to be nothing but unnecessary lines. 
         However, they are actually necessary because they help bring clarity and organization to your program. Without them, your program may be unclear and confusing.
Comments are used in a programming language to document the program and remind programmers of what tricky things they just did with the code, or to warn later generations of programmers stuck with maintaining some spaghetti code.
             While comments may seem to be a minor issue in a language, an awkward comment format in a language is a nuisance and can be a source of nasty errors. 
        The content of a comment is handled as if it were not there by the compiler.

Diagram of comment in c language

Types of Comments

        In general, the comments used in the C programming language are divided into two categories:

1. double – slash (//)and
2.  slash – star ( /* )

Double – slash comments:-

             also known as C - style comments, tell  compiler to refrain from minding the things that follow them. 
              Whatever you write after this comment, the compiler ignores. This process continues until it reaches the end of that particular line.

Slash- star comment :-

       Star comments compile to refrain from
Reading the thing of follow them. The write of comment after  slash -star  (*/) is not ready by computer always remember that  each */ to be paired with a closing */

Why using comment 

This comment can be any where. They are literally ignore by the compiler so that will not any harmed to computer programme.
       Just make sure that write the comment are correctly. Do not be confused that double -star & slash- star comment.




Please comment and follow this site blog inbox