Comments are the text that is added in C++ code to make it more readable and easy to understand. It is basically added for future reference so that whoever is going to work on that code will get additional information from comments that help them to understand the code. The compiler treats comments as white space and completely ignores them.
Two types of comments are available in the C++ programming language, single-line comments, and multi-line comments.
Single Line Comment.
Single-line comments in C++ start with two forward slashes (//) and any text written after this till the end of the line is considered a single comment.
Example of single-line comment in C++:
//This is a single-line comment //initializing an integer variable with value 5 int a = 5; int a = 10; //updating value of a
/*Below code will print the message "Hello World on the console using cout function which stands for character function. */ std::cout<<"Hello World";
No comments:
Post a Comment