Operator and its types.


           Operator and types

Operator
An operator is a symbol that indicates the compilar to perform certain maniculation (mathematical or logical) on various data item.

                    Or

Operator specified an operation to be perform that obtained a value.

For eg:
X+Y

'X'=operand
'+'=operator
Y=operand

Operand
It is a data item on which an operator acts.

Categories:

It can be classified into several categories:
1.Arithmetic operators
2.Relational operators
3.Logical operators
4.Assignment operators
5.Increment and decrement operators
6.Conditional operators
7.Bitwise operators
8.Specialperators

1.Arithmetic operators
These operators are used for numerical or mathematical calculation there are generally five arithmetic operators i.e.

Symbols.
+ = Addition
- = Substraction
* = Multiplication
/ = Division
% = Remainder (Module division)


    • Addition: The ‘+’ operator adds two operands. For example, x+y.
    • Subtraction: The ‘-‘ operator subtracts two operands. For example, x-y.
    • Multiplication: The ‘*’ operator multiplies two operands. For example, x*y.
    • Division: The ‘/’ operator divides the first operand by the second. For example, x/y.
    • Modulus: The ‘%’ operator returns the remainder when first operand is divided by the second. For example, x%y.
Module remainder can not be apply with floating point operands.It works only on integer and operands.

2.Relational operators
It is use for comparison of the value two operands.If the relation is true than the value of relational os one.If the relation is false then the value of relational expressions is zero.
OperatorDescription
==Check if two operand are equal
!=Check if two operand are not equal.
>Check if operand on the left is greater than operand on the right
<Check operand on the left is smaller than right operand
>=check left operand is greater than or equal to right operand
<=Check if operand on left is smaller than or equal to right operand
3.Logical operators
Logical operators are use to combine two or more condition or to complement the evaluation of the original condition in consitration.The result of the operator of a logical operator is a gulial value either true or false.


OperatorDescriptionExample
&&Logical AND(a && b) is false
||Logical OR(a || b) is true
!Logical NOT(!a) is false

4.Assignment operators
A value can be assigned in a variable with the help of assignment operator.Assigment operator are used to assigned the result of an expression to a variable.


  • 5.Increment-The ‘++’ operator is used to increment the value of an integer. When placed before the variable name (also called pre-increment operator), its value is incremented instantly. For example, ++x.
    And when it is placed after the variable name (also called post-increment operator), its value is preserved temporarily until the execution of this statement and it gets updated before the execution of the next statement. For example, x++.    

  • Decrement: The ‘ – – ‘ operator is used to decrement the value of an integer. When placed before the variable name (also called pre-decrement operator), its value is decremented instantly. For example, – – x.
    And when it is placed after the variable name (also called post-decrement operator), its value is preserved temporarily until the execution of this statement and it gets updated before the execution of the next statement. For example, x – –.       

    6.Conditional operator

    The conditional operators in C language are known by two more names
    1. Ternary Operator
    2. ? : Operator
    It is actually the if condition that we use in C language decision making, but using conditional operator, we turn the if condition statement into a short and simple operator.
    The syntax of a conditional operator is :
    expression 1 ? expression 2: expression
7.Bitwise operators
The bitwise operators is to perform bit level operation on the operand.The operators are first converted to bit level and then calculation is perform on the operation.The mathematical operation such as addition, Substraction, multiplication etc.  can be can be performed as bit level for faster processing.

8. Special Operator

i.) Size of operator
It is a much use in  Cprogramming language. It is a compile time unary operator which can be used to compute
the size of its operands.The result of size of is of
unsinged integral type. 

ii.) Comma Operator

The Comma Operator is a binary  operator that evaluates its first operand and discards the result, it then evaluates the second operand and return this value. The comma Operator has the lowest presidence of C operator

Comments

Popular posts from this blog

Introduction of C Language

Constant in C

Computer generation