post a comment in c programming language and statement terminator

Posted by

post a comment in c programming language and statement terminator

In this article, we are going to discuss how to post a comment in c programming language and statement terminator. Comments are parts of the source code ignored by the compiler. They do nothing but simply increase the readability and understandability of a program. Their purpose is only to allow the programmers to insert notes or descriptions within the source code. On the other hand, statement terminator has used in C and C++ language for the separation of two statements.

C++ programming language supports two types of comments. One is Single line comment and the other one is a Multiline comment.

Single line comment

It is represented by the double slash (//) symbol. It discards everything from where the pair of slashes (//) signs is found up to the end of the same line.

Multiline comment

These types of comments are represented by the symbols (/*……………*/). It ignores everything between the /* characters and the first appearance of the */ characters, with the possibility of including more than one line.

Consider the following program to demonstrate comments.

/* program to demonstrate comments in C++ */
#inlcude <iostream.h>
#inlcude <conio.h>
int main()
{
cout << “Welcome!”; // prints Welcome!
cout << “I am a C++ program demonstrating comments”;
getch();
return 0;
}

Output of the program

Welcome!

I am a C++ program demonstrating comments

In the above example, the first lines are multi-line comment while the comment at line number 6 is a single line comment.

Comments are always ignored by the compiler when it compiles the program. If comments are included within the source code of your programs without using /* or //, the compiler will take them as if they were C++ expressions.

Statement terminator (;)

Each C++ statement is terminated by a symbol named semicolon (;) which is called statement terminator. In C++, the separation between statements is specified with this ending semicolon (;) at the end of each statement. It does not matter to write more than one statement on a single line but it does matter if you do not separate them with semicolons (;). The use of each statement on a separate line is only to add clarity to the program.

post a comment in c programming language and statement terminator

Points to be remembered

C++ is a programming language developed by Bjarne Stroustrup which derives most of its features from C language.

Each C++ program makes use of header files which have definitions for C++ objects.

Pre-processor directives are the directives that are used to include header files to the C++ program.

C++ comments are the explanatory statements that are usually added to the source program statements to make them understandable to the readers.

Author Note

C++ program is one of the computer language to develop state of the art computer programs. C++ programming language is based on the object-oriented concept, through which we can create both simple and complex programs. However, this is not the only language to learn. You can learn more languages in order to make achievements in the field of computer science and software engineering. However, I recommend C++ as a startup language, through which you can develop your own skills for further advancement.

Keyword: post a comment in c programming language and statement terminator

Also Read  C Programming Constants and Variables and Naming Rules for variables

15 comments

  1. Some people (including the creator of C++) claim that there is a huge decline of quality among software developers. What seems to be the main cause?

  2. Why is C++ not a good language for data science but is great for quantitative finance even though the two subjects are almost the same from a modeling perspective?

Leave a Reply

Your email address will not be published. Required fields are marked *