0% found this document useful (0 votes)
23 views

CPP Comments PDF

Uploaded by

Sumeet Bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

CPP Comments PDF

Uploaded by

Sumeet Bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

COMMENTS IN C++

http://www.tutorialspoint.com/cplusplus/cpp_comments.htm

Copyright tutorialspoint.com

Program comments are explanatory statements that you can include in the C++ code that you
write and helps anyone reading it's source code. All programming languages allow for some form
of comments.
C++ supports single-line and multi-line comments. All characters available inside any comment
are ignored by C++ compiler.
C++ comments start with /* and end with */. For example:
/* This is a comment */
/* C++ comments can also
* span multiple lines
*/

A comment can also start with //, extending to the end of the line. For example:
#include <iostream>
using namespace std;
main()
{
cout << "Hello World"; // prints Hello World
return 0;
}

When the above code is compiled, it will ignore // prints Hello World and final executable will
produce the following result:
Hello World

Within a /* and */ comment, // characters have no special meaning. Within a // comment, /* and */
have no special meaning. Thus, you can "nest" one kind of comment within the other kind. For
example:
/* Comment out printing of Hello World:
cout << "Hello World"; // prints Hello World
*/

You might also like