What is an Operator?
Operator is a symbol that indicates the compiler to perform some
specific mathematical or logical function. There are a variety of
operators in C language.
sum = a + b;
Operand
Operator
There are variety of operators in C Language :-
1- Arithmetic Operator
2- Increment Decrement Operator
3- Assignment Operator
4- Relational Operator
5- Logical Operator
6- Bitwise Operator
7- Special Operator or Miscellaneous Operator
Arithmetic Operator
This operator is used to perform mathematical operations such as multiplication,
division, addition, subtraction on the numerical values.
Operator Operation Example
+
-
*
/
%
Addition of operands
Subtraction of operands
Multiplication of operands
Division of operands
It return remainder
3 + 2 = 5
3 - 2 = 1
3 * 2 = 6
6 / 2 = 3
10 % 2 = 0
Increment decrement Operator
There are two operations in C programming ++ and – called as Increment and
decrement operators, it used to increase the cause by one and decrease the
value by one.
Operator Operation Example(a=10)
++
--
Increments the value by one
Decrements the value by one
a++ //11
a-- //9
Assignment Operator
This operator is used to assign the value to the variable, = is most common of all
the assignment operator.
Operator Example Same as
=
+=
*=
/=
%=
a=5 a = 5
a = a+5
a = a*5
a = a/5
a = a% 5
a+=5
a*=5
a/=5
a%=5
Relational Operator
It is used to check the relation between the two operands, if the relation is true
it returns 1 if the relation is false it returns 0.
Operator Meaning of Operator Example
==
!=
>
<
>=
Check if two operand are equal 5==5 //1
5>3 //1
5<3 //0
5>=5 //1
if two operand are not equal
if operand on the left is greater than operand on the right
operand on the left is smaller than right operand
if operand on left is smaller than or equal to right operand
5!=2 //1
Logical Operator
The expression containing this logical operator returns 0 or 1 depending upon
result is true or false. It is generally used with decision making.
Operator Meaning of Operator Example (a=2, b=5)
||
!
Returns true if all are true ((a==2) && (b==5)) //True
Returns true if any one is true
Returns true when value is false
&&
((a==2) || (b>7)) //True
!(a==2) //False
Bitwise Operator
When we use this operator the mathematical or computation operation we are
doing is converted to bit level first to make the processing faster and saves
power.
a
0
0
1
1
b
1
0
1
0
a & b
0
0
1
0
a | b
1
0
1
1
a ^ b
1
0
0
1
Bitwise Operator
Left shift
a = 00010000
b=2
a<<b
01000000
Right shift
a = 00010000
b=2
a>>b
00000100
Special Operators
Operator Meaning of Operator Example (a=2, b=5)
&
*
Returns size of variable Int a; sizeof(a) //2
Returns address of the variable
Points to address of another variable
sizeof()
Int a; &a //address
int *ptr
, Used as separator and operator both a=(3,5,4) //4
Comma Operator
int a=10, b=20, c=50; //separator
int a = (5,10,18); //operator
Output  18
Because comma operator takes the rightmost value, it
evaluates all values but rejects them.
int a = 5,10,18 ; //error
int a = 5, int 10, int 18 ; //error
Let’s see Special Operators in Turbo C

What are operators?

  • 1.
    What is anOperator?
  • 2.
    Operator is asymbol that indicates the compiler to perform some specific mathematical or logical function. There are a variety of operators in C language. sum = a + b; Operand Operator
  • 3.
    There are varietyof operators in C Language :- 1- Arithmetic Operator 2- Increment Decrement Operator 3- Assignment Operator 4- Relational Operator 5- Logical Operator 6- Bitwise Operator 7- Special Operator or Miscellaneous Operator
  • 4.
    Arithmetic Operator This operatoris used to perform mathematical operations such as multiplication, division, addition, subtraction on the numerical values. Operator Operation Example + - * / % Addition of operands Subtraction of operands Multiplication of operands Division of operands It return remainder 3 + 2 = 5 3 - 2 = 1 3 * 2 = 6 6 / 2 = 3 10 % 2 = 0
  • 5.
    Increment decrement Operator Thereare two operations in C programming ++ and – called as Increment and decrement operators, it used to increase the cause by one and decrease the value by one. Operator Operation Example(a=10) ++ -- Increments the value by one Decrements the value by one a++ //11 a-- //9
  • 6.
    Assignment Operator This operatoris used to assign the value to the variable, = is most common of all the assignment operator. Operator Example Same as = += *= /= %= a=5 a = 5 a = a+5 a = a*5 a = a/5 a = a% 5 a+=5 a*=5 a/=5 a%=5
  • 7.
    Relational Operator It isused to check the relation between the two operands, if the relation is true it returns 1 if the relation is false it returns 0. Operator Meaning of Operator Example == != > < >= Check if two operand are equal 5==5 //1 5>3 //1 5<3 //0 5>=5 //1 if two operand are not equal if operand on the left is greater than operand on the right operand on the left is smaller than right operand if operand on left is smaller than or equal to right operand 5!=2 //1
  • 8.
    Logical Operator The expressioncontaining this logical operator returns 0 or 1 depending upon result is true or false. It is generally used with decision making. Operator Meaning of Operator Example (a=2, b=5) || ! Returns true if all are true ((a==2) && (b==5)) //True Returns true if any one is true Returns true when value is false && ((a==2) || (b>7)) //True !(a==2) //False
  • 9.
    Bitwise Operator When weuse this operator the mathematical or computation operation we are doing is converted to bit level first to make the processing faster and saves power. a 0 0 1 1 b 1 0 1 0 a & b 0 0 1 0 a | b 1 0 1 1 a ^ b 1 0 0 1
  • 10.
    Bitwise Operator Left shift a= 00010000 b=2 a<<b 01000000 Right shift a = 00010000 b=2 a>>b 00000100
  • 11.
    Special Operators Operator Meaningof Operator Example (a=2, b=5) & * Returns size of variable Int a; sizeof(a) //2 Returns address of the variable Points to address of another variable sizeof() Int a; &a //address int *ptr , Used as separator and operator both a=(3,5,4) //4
  • 12.
    Comma Operator int a=10,b=20, c=50; //separator int a = (5,10,18); //operator Output  18 Because comma operator takes the rightmost value, it evaluates all values but rejects them. int a = 5,10,18 ; //error int a = 5, int 10, int 18 ; //error
  • 13.
    Let’s see SpecialOperators in Turbo C