Basic Operators in Programming Languages (Examples in C++)

Basic Operators in Programming Languages (Examples in C++)

Operators are specific symbols in programming languages that tell the compiler of the program to perform specific mathematical, logical or relational operation. There are basically two main types of operator which are The built-in operator and the user-defined operator. Although; some languages restrict the user-defined operator, others do not.
Generally speaking; there are various types of operators that are used in different types of programming languages. Some of the very important types of operators are discussed below.

Arithmetic Operators:

They are the set of operators which perform basic math operations on the set of data and variables. As most of the computer programs are designed to calculate mathematical calculations, arithmetic-operators are of very important role in the programming languages.

Moreover; Just as you have to perform the very basic calculation of (1+2) and produce the output (3), you use an arithmetic-operator. In the example (1 and 2) are called to be the operands and the sign (+) is called the operator.

Some of the arithmetic-operators which are used in the programming languages are listed below in the table;

Arithmetic Operators

An example of Arithmetic-Operators in C++ Language is as below:

Read: How To Start Web Designing!???

Relational Operators:

Relational Operators are used to evaluate the relation between the operands and generate a decision on that base. For instance; when you want to compare the marks obtained by two students, you make use of the relational operator. Some of the most important relational operator that are used in programming languages are shown in the table below;

Relational Operators

An example of the relational operator in the code is a below:

Logical Operators:

Logical operators are those operators which test two conditions (mostly of the relational operators) at the same time. Furthermore; they are very important in programming because they help us to take proper decision while programming. The two main types of logical operators are discussed below:

Logical AND Operator (&&): It is used to check two different conditions at the same time. In case both the conditions are true then the value of the logical AND operator is executed as a true value. Otherwise; it will be executed as false.

For example; if a student scores above or equal to 60 and at the same time below 70, he is given the Grade B; therefore;  he needs to fulfill both the conditions here. We can write the syntax as below:

Logical OR Operator (||): It is used to check two different conditions at the same time. In this case any of the two conditions become true then the value of the logical OR operator is executed as a true value. Otherwise; it will be executed as false.

For instance; if a student is asked to bring one of his/ her parents to the office; whether he brings his/ her father or his/ her mother the condition becomes true. The syntax can be written as below:

Read: How To Make A Pyramid Shape in C++!???


This operator are the most basic operator used in the programming languages. In addition; there are other types and branches of operators, such as assignment operator, increment and decrements operators, conditional operators, ternary operators, scope resolution operators, special operators and etc. Further; will be discussed in detail soon on the same page

Feel free to ask your questions regarding our articles in the comments section.

Previous Firsts Day to Web Design: How to start Web Designing?
Next PHP Tutorials 2: Creating First PHP Project

About author

Bahonar Javid
Bahonar Javid 43 posts

<p>* Computer Application Student<br /> * Co-Founder of<br /> * Love to code and Learn new languages<br /> * Enjoy playing football</p>

View all posts by this author →

You might also like