We can write comments in our code for easy understanding and future maintenance of the script. Writing comments are good habit.
Statements written after // are treated as comments and ignored by C complier
int num ; // This part is comment
In the above statement we have declared num as a integer variable and then written a comment after //
IN the above code we have seen how to write comments in each line. What is written after // is treated as comment and not executed by compiler. The next line is treated as code again. To make a bulk of statements including more than one line we have to use /* (starting of comment ) and then */ ( ending of comment portion )
These are comments
This is part of comment and will be ignored by C compiler
So once we use /* to start comment , then all statements written till end of comments marked by */ is ignored by compiler.
Nested comments are not allowed. So this line will generate error.
/* comments /* some more */ again some more */
In the above line the portion after */ will not be taken as comments so it will create problem. Here are some examples of writing comments .
float num; // declaring a float variable
/* We can assign value to our variable like this */
printf("num = %5.3f", num);
/* this is a part of plus2net
c tutorial basic section
you can learn more advance features here