# Operators in C – tccicomputercoaching.com

## What is operator?

Operator means simple symbol which is used between operands (variable) during
mathematical process. There are following categories:

## i.e.

a=6

b=2

printf(“a+b =%d”, a+b);

printf(“a-b =%d”, a-b);

printf(“a/b =%d”, a/b);

printf(“a*b =%d”, a*b);

printf(“a%b =%d”, a%b);

op:

a+b =8

a-b =4

a/b =3

a*b =12

a%b =0

Modulor Operator – % is used in Coding like ro find Number is even or Odd.

if(a%2==0)

{

printf(“a is even”);

}

else

{

printf(“a is odd”);

}

## 2. relational operator : > >= < <= == !=

For example,

a=6

b=2;

if(a==b)

{

printf(“a and b are same”);

}

else

{

printf(“a and b are not same”);

}

## 3. logical operator : && || !

&& ||

—————————————————————————————————————–

c.1 c.2 Result c.1 c.2 Result

—————————————————————————————————————–

1. T T T T T T

2. F T F F T t

3. T F F T F t

4. F F F F F F

## 4. Assignment Operator: =

This operator assign value of right side variable to the left side
variable.

i.e int x=10,y=20 ;

printf(“%d”,x);

x=y;

printf(“%d”,x);

op:

10 20

## 5. Increment and decrement: ++ – –

Increment ++ and decrement — to change the value of an operand (constant or variable) by 1. Increment ++ increases the value by 1 whereas decrement — decreases the value by 1. These two operators are unary operators, meaning they only operate on a single operand.

i.e,

int x=6;

x++;

printf(“%d”,x);

x- -;

printf(“%d”,x);

## 6. Conditional operator:

Syntax: exp1? exp2:exp3

I.E. int x=10,y=20 ,max;

max=x>y?x:y;

printf(“%d” ,max);

OP: 20

i.e

int x=6;

x+=5;

x= 6+5;

x=11;

## 8. Bitwise Operators : & | > <

The Bitwise operators is used to perform bit-level operations on the operands. The operators are first converted to bit-level and then the calculation is performed on the operands. The mathematical operations such as addition, subtraction, multiplication etc. can be performed at bit-level for faster processing. For example, the bitwise AND
represented as & operator in takes two numbers as operands and does AND on every bit of two numbers. The result of AND is 1 only if both bits are 1.

i.e

Assume variable ‘A’ holds 60 and variable ‘B’ holds 13, then –

(A & B) = 12, i.e., 0000 1100