♠ Posted by Unknown in C'Language at 23:47
Operators are available in C language:
C supports a rich set of operators. An operator is a symbol that tells the
computer to perform certain mathematical or logical manipulations. Operators are used in programs to manipulate
data and variables. They usually form a
part of the mathematical of logical expressions.
C operators can be classified in to a number of
categories. They include:
1. Arithmetic Operators.
2. Relational Operators.
3. Logical Operators.
4. Assignment Operators.
5. Increment and Decrement Operators.
6. Conditional Operators.
7. Bitwise Operators.
8. Special Operators.
OPERATORS: |
|
ARITHMETIC OPERATORS |
|
+
|
This operator is used
for addition and unary plus.
|
-
|
This operator is used for subtraction and unary minus.
|
*
|
This operator is used for multiplication.
|
/
|
This operator is used for division.
|
%
|
This operator is used for division and find the
remainder (Modulo Division)
|
RELATIONAL OPERATORS |
|
<
|
This operator checks “is less than”.
|
>
|
This operator checks “is greater than”.
|
<=
|
This operator checks “is less than or equal to”.
|
>=
|
This operator checks “is greater than or equal to”.
|
==
|
This operator checks “is equal to”.
|
!=
|
This operator checks “is not equal to”.
|
LOGICAL OPERATORS: |
|
&&
|
Logical AND
|
||
|
Logical OR
|
!
|
Logical NOT
|
SHORT HAND ASSIGNEMENT OPERATORS: |
|
=
|
This operator is used to assign the result of an
expression to a variable.
|
+=
|
Means a = a + 1 à a += 1
|
-=
|
Means a = a – 1 à
a -= 1
|
*=
|
Means a = a * 1 à
a *= 1
|
/=
|
Means a = a / 1 à
a /= 1
|
INCREMENT AND DECREMENT OPERATORS: |
|
++
|
This operator add 1 to
operand.
|
--
|
This operator subtract 1 from the operand.
|
CONDITIONAL OPERATOR (TERNARY OPERATOR PAIR) |
|
exp?exp2:exp3
|
The operator ?: works as follows: exp1 is evaluated
first. It is nonzero (true), then the
expression exp2 is evaluated and becomes the value of expression. If exp1 is false, exp3 is evaluated and its
value becomes the value of expression.
|
BET WISE OPERATORS: |
|
C has distinction of supporting special operators known
as bitwise operators for manipulation of data at bit level.
|
|
&
|
Bitwise AND
|
|
|
Bitwise OR
|
<<
|
Shift Left
|
>>
|
Shift Right
|
~
|
One’s complement
|
^
|
Bitwise exclusive OR
|
SPECIAL OPERATORS: |
|
The Comma Operator |
The comma operator van be used to link the related
expression together.
|
The Sizeof Operator |
The sizeof operator is normally used to determine the
length of arrays and structures when their sizes are not known to the
programmer.
|
0 comments:
Post a Comment