Home » Statements, Statement Terminator, and Comments In C++

Statements, Statement Terminator, and Comments In C++1 min read

Fundamentals Of C Plus Plus Programming

by TechABU
Statements, Statement Terminator, and Comments in C++

Statements In C++

A C++ statement is a single or multiple expression that has the ability to produce results. It’s a command to the computer to perform a task. cout <<“C++ Statements!”; is an example of a C++ statement. The following are some statements that can be used as examples.

coût<< " I'm a C Plus Plus Statement! "; 

The only action performed by this statement is to display the results “I’m a C Plus Plus Statement!” on the screen.

The whole statement means to insert a sequence of characters (in this example, the ‘I’m a C Plus Plus Statement!’ series of characters) into the standard output stream, and cout is the name of the standard output stream in C++. The standard header file < iostream.h > declares cout.

Statement Terminator (;) In C++

Each C++ statement is concluded by a symbol called a statement terminator, which is a semicolon (;). The semicolon (;) at the end of each statement in C++ specifies the distinction between statements. It doesn’t matter if you put many statements on a single line, but it does matter if you don’t use semicolons to separate them. The usage of each statement on its line is only to add clarity to the program.

Comments and Their Syntax In C++

Comments are pieces of source code that the compiler ignores. They have no effect other than to make the code more readable and understandable. Their sole function is to allow programmers to add comments or descriptions to the source code. There are two sorts of comments in C++.

#1 – Single Line Comments In C++

The double slash // symbol represents it. It discards everything from where the pair of slashes signs // is found to the end of the same line.


// Your_Comment_Here

#2 – Multi or Double Line Comments In C++

The symbol /*……. */ is used to indicate double-line comments. The compiler ignores everything between these two symbols and considers it to be a blank space. When programmers require several line comments, this form of comment is used.


/* Your_Comments_Here */ 

C++ Program example that will demonstrate the concept of statements, statement terminator (;), and comments in CPP.

#include <iostream>
#include <conio.h>
using namespace std;

int main()
	cout << "Welcome! I'm a C Plus Plus Statement "; //This line is a C++ statement ending with a semicolon (;)
	This is a double-line comment. Everything that I write here will not be displayed in the output.
	return 0;

Leave a Comment


Send this to a friend