operators in c
OPERATORS & EXPRESSIONS
An operator is a symbol that tells the compiler to perform a certain mathematical or logical
manipulation.
Operators are used in programs to manipulate data and variables.
Expressions combine variables and constants to produce new values.
Categories of Operators
1. Arithmetic Operators
2. Logical Operators
3. Relational Operators
4. Increment and Decrement Operators
5. Assignment operators
6. Bitwise Operators
7. Other Operators - Comma Operator, sizeof operator, ternary operator ?:, reference operator
&, dereference operator * , member selection operators
ARIHMEIC OPERATOR:
Operator:
+ addition or unary plus
- subtraction or unary minus
* multiplication ;
/ division
% remainder after division
(modulo division)
LOGICAL OPERATORS
Operator Meaning Example
&& Logical AND. --> True only if all operands are true
|| Logical OR. --> True only if either one operand is true
! Logical NOT. --> True only if the operand is 0
RELATIONAL OPERATORS
Operator:
== Equal to
> Greater than
< Less than
!= Not equal to
>= Greater than or equal to
<= Less than or equal to
INCREMENT AND DECREMENT OPERATORS
Increment and decrement operators are used for adding and subtracting one from the current value of
the variable. The increment and decrement operators can be categorized into pre and post operators
Pre Increment and Pre Decrement Operators:
The pre operators, like pre increment and pre decrement, the value of the variable is first incremented
or decremented and then the value of the variable is returned.
Post Increment and Post Decrement Operators:
In case of post, like post increment and post decrement , the current value of the variable is returned
and then it is incremented or decremented
ASSIGNMENT OPERATORS
Used for storing a value in a variable. The shorthand assignment
operators are used for combining the operator and assignment
Operator Example Same as
= a = b a = b
+= a += b a = a+b
-= a -= b a = a-b
*= a *= b a = a*b
/= a /= b a = a/b
%= a %= b a = a%b
BITWISE OPERATORS
Bitwise operators are special operator set provided by 'C. ' They are used in bit level programming. These operators are used to manipulate bits of an integer expression. Logical, shift and complement are three types of bitwise operators.
Operators
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
~ Bitwise complement
<< Shift left
>> Shift right
Comments
Post a Comment