Comments in C++ | Single line comments in C++ | Multiline comments in C++
Comments in C++
Comments are user defined messages written by a programmer inside a program.
Comments can be used to mention program name, program’s purpose or any information which can be helpful at a later stage for review of the program. Compiler ignores comments.
Comments in C++ can used in two ways:
- Single Line comment
- Multi Line comment
(i) Single Line comments in C++
These types of comments start with // (Double slash). This type of comment remains till the end of line in which it appears.
Example
//This is a comment
(ii) Multi Line comments in C++
These types of comments start with /* (Slash asterisk) and end with */ (Asterisk Slash). They can be used if the comment goes across multiple lines.
Example
/*This is a multi line comment. */
//Program to demonstrate the use of comments
/* Developed By: Lovejot Date: 26-07-2024 */ #include<iostream> using namespace std; int main() { cout<<”Comments Program”; return 0; }