How do you add comments to your code?

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Comments Vertex Academy

It’s very often necessary to add some comments when you're writing a program.

For example:

  • This block code is responsible for…
  • This variable is responsible for…
  • etc.

Believe me, it’s a very good practice to add comments. As a result:

  • It will always be easy for you to remember what does what in your program. It often happens that a person writes a code and then opens it a month later and can't believe that they were the one who wrote it. But if you leave comments, the shock won't be as great.
  • And anyone who works on your code after you will be grateful. After all, you might not be at your colleague's side when they read your code. If you don't leave comments, they may be confused and unable to understand why you wrote what you wrote.

That’s why you should add comments – to take care of yourself and future programmers.

So how do you add a comment? Let’s look at the example below:

Example No. 1

 The example shows that if a comment occupies one line, then we use two slashes // and write our comment.

If a comment occupies two or more lines, then we need to use the following construction:

Well, now you know how to add comments in code. Our article's mission has been accomplished. Here's a Latin proverb which can apply to comments as well:

"Preserve order and it will preserve you."

 

 

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr