A comment is a piece of text within a program that is not executed. It can be used to provide additional information to aid in understanding the code.
Single-line comments are created using two consecutive forward slashes. The compiler ignores any text after
// on the same line.
// This line will denote a comment in C++
Multi-line comments are created using
/* to begin the comment, and
*/ to end the comment. The compiler ignores any text in between.
/*This is all commented out.None of it is going to run!*/
Here’s a program with a multi-line comment and two single-line comments:
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- Christine_Yang271 total contributions