03 – C++ : Comments


Cplusplus Comments

We can say that program comments are important when you are writing a C++ code for your program because it serves as explanatory statements or let’s just say it’s a note to yourself that you put in the sourcecode ( best done before you actually write the codes ). These comments also help anyone reading the sourcecode and make them understand what you’re trying to do.


You can write as many characters as you like because C++ supports single line and multi-line comments. And don’t worry because all comments are ignored by the complier.


/* is used when you start to write C++ comments and it ended up with */.


/* Example of comment */

/* comments in c++  can also be
 * in multiple lines


You can also start with //, enhancing to the end of the line.


#include <iostream>
using namespace std;

   cout << "Howdy World...."; // Display Howdy World....

   return 0;


In the example above,  it will ignore the // Display Howdy World….  and execute the codes that you put. This will be the result.

Howdy World.....


Inside the /* and  */ the code have no value at all. See example below.


/* Comment out Displaying of Howdy World....:

cout << "Howdy World...."; // Display Howdy World....

Facebook Comments
(Visited 52 times, 1 visits today)


Please enter your comment!
Please enter your name here