This article covers the various Operators in C++
An integral part of any programming language, operators help form the base of C++. Used for a wide variety of purposes such as comparison, assignment, logic gates and arithmetic operations, operators come in many different types.
Below we’ve categorized all these operators into their respective sections.
Arithmetic operators are used with numerical values to perform different mathematical operations on number. Listed in the table below are all the C++ Arithmetic Operators.
|Addition||+||The Sum of two numbers.|
|Subtraction||–||Difference of two numbers.|
|Multiplication||*||Product of two numbers.|
|Division||/||Division of two numbers.|
|Modulus||%||Remainder of the division of two numbers.|
|increment||++||Increments the number by 1|
|decrement||—||Decrements the number by 1|
Probably the most commonly used, the Assignment Operators are used to assign values to variables. See the full list of C++ Assignment operations below and their regular equivalents.
Comparison Operators are used to compare the contents of one variable to the other. If the Comparison holds true, then the Boolean value “True” is returned. However if the comparison is false, then the Boolean value “False” is returned.
| ||Equals to|
| ||Not Equal to|
| ||Greater than|
| ||Greater than or equals to|
| ||Less than|
| ||Less than or equals to|
Logical operators allow a program to make a decision based on multiple conditions (variables). The values of these variables decide the flow of the program.
|&&||And||Returns true if both statements are true|
|||||Or||Returns true if one of the statements is true|
|!||Not||Inverses the result. (True if False, False if True).|
This marks the end of the C++ Operators article. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the article material can be asked in the comments section below.