C++ Operators
C++ Operators
Operators are the symbols that are used to perform operations. such that, arithmatics, logical and etc operations Operators are of 3 Types which are furthur classified:-
These are
- Unary Operators
- Binary Operators
- Ternary Operators
which are increment(++) and decrement(--)
Increment are of two types Pre-increment and Post-increment
Pre-increment ++x, where x is a variable
Post-increment y++, where y is a variable
Similary, Decrement are of two types Pre-decrement and Post-decrement
Pre-decrement --i, where i is a variable
Post-decrement j++, where j is a variable
Binary Operators are those which work on two operands.
They are of 5 Types:-
- Arithmatic operators
- Relational operators
- Logical operators
- Bitwise operators
- Assignment operators
Arithmatic Operators:- As the name identify, this operator are used to perform mathematicals calculation. These are of 5 types:- +, -, *, /, %.
Addition operator(+), Subtraction operator(-), Multiply operator(*), Division operator(/), and
Modulus operator(%) which is used to give remainder.
Logical Operator:- It is used to combine two or more operands. These are &&, ||, !
Logical AND(&&)
Logical OR(||)
Logical NOT(!)
Bitwise Operators:- These operators are used to perform calculation on bit level.
These are &,|,<<.>>,~,^.
Assignment Operators:-assigns the value of its right-hand operand to a variable, a property, or an indexer element given by its left-hand operand.=,+=,*=,/=,%=.
Ternary Operators
These are those operators which work on 3 operands, it is also known as Conditional Operator
Syntax of Ternary Operators:-
?:
Example:-
if(num%2==0)?cout<<"even";:cout<<"odd";
Comments
Post a Comment