Hello Everyone, Welcome back to Think & Free. Here is another episode of Express Learning Programming with the GNU C Programming Language Programming Series. Today I’m going to show you What and, How to Use Comments in C.
What is Comments?
In Every programming language, Comments are used to take notes about codes. It helps to make the program easier for developers. Another thing is
comments are used to sometimes, temporarily deactivate some code lines.
In Compiler Programming Languages, the Compiler will ignore Comments during the compilation process. That means the compiler didn’t include comments for compiled files. The Comments only allowed the Developer can see, create & edit. In Interpreted Programming languages, The interpreter will be ignored to interpret Commented code lines.
Let’s see how can we use it.
Comments in C
Comments and their Syntax will differ from language to language. Basically in C Programming Language, we can see two types of comments. Let’s look at what are they.
- Multi-line or Block Comments
- Single-line Comments
These are the two types of Comments we can use in the GNU C Programming Language. The multi-line comments will allow you to create a block of comments or something like a paragraph or something like that. All these comments can be used in anywhere in your program, comments are not location specified.
C Multi-line Comment
In this type of comments will allow you to set multi-line comments in C, it’s like you can use some comments like paragraphs. let’s see how to use this type of comment in C.
Multi-line comments will start with /* and end with “*/
“, in every content in these “/* */” blocks will ignore the compiler in the compilation process. it’s only allowed for the developer to take note of codes.
C Single-line Comment
Here is another type of Comment syntax we can use in the C Programming language. let’s see how to use it. If in any line we can start this type of comment using “//
“.
Here is the example code below,
/* C comments Example by Think & Free This is a Multi line comment in C Here is the third line. */ #includeint main() { // Print 'Hello, World' String on Console window printf("Hello, World\n"); return 0; }
Look at the code, now you can compile and run this code, and see the result (If you don’t have an idea of how to compile and run C code. check out our previous lesson). It will only provide, output for “printf("Hello, World\n");
“. I think that’s enough to, Get some idea about “Comments” in C. See you back soon with another episode of this Express Learning Programming win GNU GCC Programming Language. “Practice is the only way to learning.