C++ comment style - Learn C++ programming

Today, we will learn C++ Comment Style | Learn C++ programming, the Comment has two types in C++, In this chapter, we talk about maximum, We hope, you understand easily. Please comment below to give us feedback.

In this C++ programming tutorials for beginners video series, and you will learn the usage of comments with examples.

So, readers, You will learn what are comments here, then what types of comments are there in c++, how to use them, what are single-line comments, what are multi-line comments, or paired comments when to use comments in c++ in detail.

In this article, I am explaining C++’s first tutorial with the help of Comments and then explain What is Comment in C++. our C++ program was:

C++ Comment Style Example:

1. #include <iostream>  
2. // #include is a method to connect any library.
3. // <iostream> is pre built library of C+  

Line no# 1, we use #include. it means we are entering or attach something in the program and in the old days, we use the <iostream.h> at the top of every c++ program. but in the modern generation,

So, we use <iostream> with the 2nd line using namespace std; this is a library in which the developer of c++ declared the all meaning’s of all c++ reserve words like cin, court, etc… and this file called a header file. In this course of C++, I will teach you more about header files.

3. int main() // int is a data-type of function

line no# 3, “int” is a Data_type of a program. the full form of int is “Integer” Integer’s Example is {1, 2, 3, 4, 5, 6, 7, 8, 9} and the “main()” is a function. whose we use it regularly in C++| cpp files, which we write our leading program code.

line no# 4 and 7, So, We use the open curly brackets and close curly brackets. every function start with

                     // here your leading program code...

In Line no# 5, We use “cout”, “<<“ and ends with “;”. This method is for printing the text on screen and we need to put semicolon in end of every statement.

In the Last, line no# 6, this statement is for using to give return value of the C++ program, and in this program, this code will return the integer value 0.


1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5.    cout << "Hello World!";
6.    return 0;
7. }

So, here start the top of Comments in c++

There are two types of Comments in C++

  1. Single line Comment
  2. Multi-line Comments

In C++ programming, we use the Single line comment and we write it in a one-line for a short description of a program or short function and the Single line comment method of writing is:


1. // This is single line comment method
2. // the comments are invisible at the time of compiling and running the program

So, In C++ programming, we use the Multi lines comment in more than one line for a short and long description of a program or a function, the Multi lines comment method of writing is:


1. /*
2. Here we can write and hide full programm.
3. #include <iostream>
4. using namespace std;
5. int main()
6. {
7.    cout << "Hello World!";
8.    return 0;
9. }
10. */


1. /*
2. Here we can write and hide full programm/Function/Any code of line
3. with the use of /* Data */
C++ comment style and Learn C++ programming

So, here is our Recent Topic

  1. Introduction to C++ Programming then follows the number two.
  2. C++ Syntax – Learn C++ Programming and then follows the number Three.
  3. Comment in C++ – Single-line & Multi-line and then follows the number Four.
  4. C++ Output (Display Text) – C++ New Lines and then follows the number Fiver.
  5. C++ Variables and Learn C++ Programming and Learn C++ Complete.

By Usama Arshad

It's me Usama Arshad working as a Lecturer C++. I am a student of BSIT.