Operators in C++

A variable, when declare of a particular type is a set of legal operations that can be performed on it. For example, when integer are declared operation such add, subtract, multiply and divide can be performed them. Operators perform those operations on the variables.
Different types of operators available in C++ are:-
  1. Arithmetic operators - are +, -, *, / and % operator. % operator divide the second value from the first and return the remainder.
  2. Relational operators - are >, >=, <, <=, ==, !=. These operators compare two values and return the appropriate result.
  3. Logical operators - are && and ||. This operator evaluates two expression, and evaluation stops as soon as the true or false value of result is known.
  4. Unary operators - The unary operators operate on one operand- variable or constant. C++ provides the two unary operators ++ and -- for incrementing and decrementing variables. The increment operator add 1 to its operand while decrement operator subtracts 1. The operators can also be used either prefix or postfix operators.

No comments:

Post a Comment