C++ Operators ?
Operators is a special symbol that tells the compiler to perform specific mathematical or logical Operation. Java supports following lists of operators.Operators are a useful and powerful feature of the C/C++ programming language. Without them, the functionality of C is useless. It makes it easy for a programmer to write codes very efficiently and easily.
“An operator is a symbol that specifies the operation to be performed on various types of operands.(operand may be a constant or variable or function which return a value). An operator may be associated with one or two or three operands.
Example:- a + b
a - b
a * b
Classification of Operators based on operands.
- Unary Operators:-An operator that operates on one operand to produce a result is called unary operator.
Example:--10,-a, *b etc. - Binary Operators:-An An operator that operates on two operands in an expression to produce a result is called a binary operator.
Example:-a+b, a*b etc. - Ternary Operators:-An operator that operates on three operands to produce a result is called a ternary operator.
Example:-a?b :c
Classfication based on the types of operation:-
-
Arithmetic Operator>
The operators that are used to perform arithmetic operations such as addition( + ), subtraction( - ), multiplication( * ), division( / ), and modulus (%) operations are called arithmetic operators.
Example:- +, - , * - Relational Operator
The operators like <, >, =, != etc. that are used to find the realtionship between two operands are called relational operators.
Example:- < , >= , > ,<= - Logical Operator
Logical operators are used to check (or) compare the logical relations between the expressions. Logical operator, returns 1 if given condition is true, 0 if given condition is false.
Example:-&& , ||, !, - Assignment Operator
An operator which is used to assign the data or result of an expression into a variable is called an assignment operator ( = ).
Example:- = , += - Increment Operators
++ is an increment operator. This is a unary operator. It increments the value of a variable by one.
Example:- ++ , -- - Conditional Operator
The conditional operator is sometimes called a ternary operator because it involves three operands. The conditional operator contains a condition followed by two statements or values. If the condition is true the first statement is executed, otherwise the second statement or value.
(exp1)?exp2:exp3;
Example:- ?: - Bitwise Operator
The operators that are used to manipulate the bits of given data are called bit wise operators.
Example:- & , ^ - Special Operators
There are various types of special operators.- Comma Operators(The Comma operator can be used to link the related expressions together.)
- size of Operator(size of returns the size of a variable or datatype.)
- pointer Operator(it is a complement of &. It is a unary operator that returns the value of the variable at the address specified by its operand.)
- address Operator(The reference operator noted by ampersand ("&"), is also a unary operator in c languages that uses for assign address of the variables. It returns the pointer address of the variable. )
Copyright © 2022 Shineskill Software Pvt. Ltd., All rights reserved.