Comments in C++

Advertisements

Compile in C++ Keywords in C++

How to Write Comments in C++

Generally Comments are used to provide the description about the Logic written in program. Comments are not display on output screen.

When we are used the comments, then that specific part will be ignored by compiler.

In 'C++' language two types of comments are possible

  • Single line comments
  • Multiple line comments

Single line comments

Single line comments can be provided by using / /....................

Multiple line comments

Multiple line comments can be provided by using /*......................*/

Note: When we are working with the multiple line comments then nested comments are not possible.

comment in c++

Rules for Writing Comments

1. Program contains any number of comments at any place.

Example

// header files
#include<iostream.h>
#include<conio.h>

void main()
{
// variable declaration
int a,b,c;
a=10;
b=20;
c=a+b;
cout<<"Sum: "<<c;
getch();
}

2. Nested Comments are not possible, that means comments within comments.

Example

void main()
{
/*
/*      comments   */
*/
}

3. Comments can be splits over more than one line.

Example

void main()
{
/* main   
   function
   body part
*/
}

4. Comments are not case sensitive.

Example

void main()
{

/*  MAIN Function BODY   */

}

5. Single line comments start with "//"


Compile in C++ Keywords in C++

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements