OPERATORS

Every language contains variable and data types and also support the concept of operators. C language has over forty operators, but hardly all they are used. These are divided onto nine categories:-

(1) Arithmetic

(2) Assignment

(3) Logical

(4) Relational

(5) Modulas

(6) Increment / Decrement

(7) Conditional

(8) Bit wise

(9) Special


Arithmetic Operators (+ - * /)

These are the common operators used to perform any arithmetic calculations. These are basically used on minimum two variables or constants. These operators contain +, -, *, /.

Assignment Operators

These operators are used to assign any value to the variable or constant. The main assignment operator is ‘=’.

We have some short assignment operators. Suppose a=10







Logical operators

These are used to test more than one condition or we can say conditional expression, so that you can make a decision on the basis of that condition. These operators are






Relational operators

These operators are also called comparison operators. You can use relational operators, whenever you want to compare two quantities and variables or constants and you want to take decision on the basis of that condition. Then these operators are used.

We have following types of operators:-

>

<

>=

<=

==

!=

Modulas Operator

This operator is used to find out the reminder of any value.

R=25%10 R=5

Increment / Decrement operators

These operators are also called unary operators. These operators are used when we want to perform any action on single operand. These operators are used when we want to increase or decrease value of any variable by one.

Increment operator is ++

Decrement operator is

We have two types of unary operators

Post fix

This operator is used to assign any value of variable to another variable according to use requirement. In this operator firstly the value of a variable is copied to another variable and then the value is increased or decreased.

a=10

a++ a=11

Pre-fix

This operator is used to assign value to any variable according to user requirement, so that the same value is copied to another variable. Firstly the value of variable is increased or decreased and then it is copied to any other variable.

a=10

++a a=11

Conditional operators

These operators are also called ternary operators. These are used to check any condition or expression and can be used to compare two conditional expressions and produce a result if the condition is true or false. Operators used for conditional operators are “?” and “:”

Syntax:-

(expression / condition)? True statement (if) : false statement (else)

Bit wise operators

C is known as assembly language because it provides us bit wise operators, which are normally associated with assembly language programming. C language has a powerful set of special operators which are capable of manipulating data at bit level. These are as follows:-

1) & - Bit wise (and)

2) ! - Bit wise (or)

3) ^ - Bit wise (exponent)

4) << - Shift left

5) >> - Shift right

Special operators

Special operators are provided by C. these operators are as follows:-

  1. commas operators (,)
  2. pointer operators (*, &)
  3. sizeof ( )


Relational operators

These operators are also called comparison operators. You can use relational operators, whenever you want to compare two quantities and variables or constants and you want to take decision on the basis of that condition. Then these operators are used.

We have following types of operators:-

>

<

>=

<=

==

!=

Modulas Operator

This operator is used to find out the reminder of any value.

R=25%10 R=5

Increment / Decrement operators

These operators are also called unary operators. These operators are used when we want to perform any action on single operand. These operators are used when we want to increase or decrease value of any variable by one.

Increment operator is ++

Decrement operator is

We have two types of unary operators

Post fix

This operator is used to assign any value of variable to another variable according to use requirement. In this operator firstly the value of a variable is copied to another variable and then the value is increased or decreased.

a=10

a++ a=11

Pre-fix

This operator is used to assign value to any variable according to user requirement, so that the same value is copied to another variable. Firstly the value of variable is increased or decreased and then it is copied to any other variable.

a=10

++a a=11

Conditional operators

These operators are also called ternary operators. These are used to check any condition or expression and can be used to compare two conditional expressions and produce a result if the condition is true or false. Operators used for conditional operators are “?” and “:”

Syntax:-

(expression / condition)? True statement (if) : false statement (else)

Bit wise operators

C is known as assembly language because it provides us bit wise operators, which are normally associated with assembly language programming. C language has a powerful set of special operators which are capable of manipulating data at bit level. These are as follows:-

1) & - Bit wise (and)

2) ! - Bit wise (or)

3) ^ - Bit wise (exponent)

4) << - Shift left

5) >> - Shift right

Special operators

Special operators are provided by C. these operators are as follows:-

  1. commas operators (,)
  2. pointer operators (*, &)
  3. sizeof ( )