Thursday, November 23, 2017

Comments

Now we are familiar with the basic structure of a simple c program, right?. Now it's time to talk about another important thing.

Here we will discuss about how to put a Comment on a C/C++ program:

Comments are specially important for large projects where thousands of lines of source code or many contributors are working on the same source code. When we use our pre written code or simply older code, sometime it is tough to understand everything properly.
That’s why there is a way for adding comment in our program so that we can add some hints which will help us or other contributors when they use the same source code.


Process of adding a comment is more simpler than our above explanation :D There are two different way we can use in C/C++ programming to add a comment.



Let’s look into the source code below :


#include <stdio.h>

int main() 
{
     // Way 1: This a single line comment.
 
     /* Way 2: This style
     allow you to add
     multiple lines 
     of  comments. */
  
     printf("This is an Example of adding Comments on a C program in different way.");
     return 0;
}

OUTPUT


If we use to any particular line in our source code then whatever we write after the sign on that line will be ignored by the compiler.


If we use to our code then whatever we write inside that will be ignored by the compiler.


Previous Topic

Next Topic



No comments:

Post a Comment