Comments in C++ are quite easy to understand and are just for your clarity. They are ignored by the compiler and are not executed. C++ comments in one line begin with two slashes '//'. For example-
//Program to print 'Hello World!' #includeusing namespace std; int main() { cout<<"Hello World!"; return 0; }
You can write comments in multiple lines by either adding '//' before each line or you can begin it by adding '/*' at the start and ending by adding '*/' at the end. For example;
/*This is a comment in two lines*/ #includeusing namespace std; int main() { cout<<"Hello World!"; return 0; }
Comments are ignored by the compiler and are only used for clarity of the code to make it more understandable for the user. It is your choice if you want to put comments in a program or not.
That is all for this post. Follow my blog to know more about coding languages.
Regards,
Aarav Iyer
References:
(1) https://www.w3schools.com/cpp/cpp_comments.asp