Comments in C++ | Topic 2 | VU Insider

Comments are often used to make the code more readable or to explain the code in details.

There are two ways to use comments in C++ language:
  •  Single-lined 
  • Multi-lined

Single-lined comments:

Any text after two forward slashes (//) will be ignored by the compiler and hence we can use it as comment section. (only for single line)

// This is a comment  cout<<"Hello World";code-box
Or we can also use single-line comment as;  cout<<"Hello World"; // This is a commentcode-box

Multi-lined comments: 

It starts with "/*" and ends with "*/". Any text between "/* and "*/" will be ignored by the compiler.

/* This is a comment. The code below will print out "Hello World" to the screen */ cout<<"Hello World";code-box

Post a Comment

Previous Post Next Post