## Description

Operator is a symbol that tells the computer to perform the mathematical and logical opeation in c programming. Operators are used in program to manipulate the data and variable. An Operator operates on variable to perform the action in a program.

**Different types of Operator :**

- Arithmetic Operators
- Relational Operators
- Logical Operators
- Assignment Operators
- Increment and Decrement Operator
- Conditional Operator
- Bitwise Operator
- Special Operator

**1. Arithmetic Operators : **An Arithemetic operator is a symbol which performs the Mathematical Operation like that Addition, Subtraction, Multiplication, Division etc. The Arithmetic operators perform between variables and consonant.

Operators | Symbol | Form | Operation |
---|---|---|---|

Multiplication | * | x * y | x times y |

Division | / | x / y | x divided by y |

Remainder | % | x % y | remainder of x divided by y |

Addition | + | x + y | y is added to x |

Subtraction | - | x - y | y is subtracted from x |

**2. Relational Operator : **Relational operators are used to compare the values between two variables. Relational Operators Table Below....

Operator | Meaning |
---|---|

< | less than |

<= | less than or equal to |

> | greater than |

>= | greater than or equal to |

== | equal to |

!= | not equal to |

**3. Logical Operator : **The logical operator is used for when we want to check the condition and for making the decisions in programs.

Operator | Meaning |

&& | logical AND |

|| | logical OR |

! | logical NOT |

**4. Assignment operator : **The assignment operator is represented by the equal sign (=). The variable appearing on the left side of = sign and it is assignment the value appearing on the right side of this sign. There are many types of assignment operator.

Operator | Expression | Example |
---|---|---|

+= | x+=y | x = x + y |

-= | x-=y | x = x - y |

/= | x/=y | x = x / y |

%= | x%=y | x = x % y |

**5. Increment and Decrement operator : **The increment and decrement operators in c are represented by ++ and -- sign respectively. The operator ++ means "add by 1" and the operator -- means "subtract by 1".

**6. Conditional Operator : **A ternary operator pair with "? :" is available is C to construct conditional expression of the form.

**exp1?exp2:exp3**

Where exp1 , exp2 and exp3 are expressions.

**7. Bitwise Operator : **Bitwise operator is special operators which are used for manipulations of the data at bit level. These operator are used for testing the bits, or shifting them right or left. Bitwise operators may not be applied to float or double.

Operator | Meaning |
---|---|

& | bitwise AND |

| | bitwise OR |

^ | bitwise exclusive OR |

<< | shift left |

>> | shift right |

Type Conversion is a process of converting operators of different data type into a common data type. If we use two or more different types of data items together in an expression, the c language compiler automatically carried out the conversion of the data types whenever needed.

**Two types of Types Conversion.**

**1. Implicit type conversiont : **C permits mixing of constants and variables of different types in an expression. C automatically converts any intermediate values to the proper type so that the expression can be evaluated without losing any significance. This automatic conversion is known as implicit type conversion.

**2. Explicit type conversion : **C performs type conversion automatically. However, there are instances when we want to force a type conversion in a way that is different from the automatic conversion. This problem can be solved by conveting locally one of the variables to the floating point as shown :

ratio = (float)female_number/male_number

The proecess of such a local conversion is knownas explicit conversion or casting a value.

Precedence determines the grouping of terms in an expression and decides how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has a higher precedence than the addition operator.

Associativity is the left-to-right or right-to-left order for grouping operands to operators that have the same precedence. An operator's precedence is meaningful only if other operators with higher or lower precedence are present. Expressions with higher-precedence operators are evaluated first.

Table of Associativity below...

Description | Operator | Associativity |
---|---|---|

Function expression | () | Left to Right |

Array expression | [] | Left to Right |

Structure operator | -> | Left to Right |

Structure operator | . | Left to Right |

Unary Minus | - | Right to Left |

Increment/Decrement | ++/-- | Right to Left |

One's Complement | ~ | Right to Left |

Negation | ! | Right to Left |

Address of | & | Right to Left |

Value of address | * | Right to Left |

Type case | (type) | Right to Left |

Size in bytes | sizeof | Right to Left |

Multiplication | * | Left to Right |

Division | / | Left to Right |

Modulus | % | Left to Right |

Addition | + | Left to Right |

Subtraction | - | Left to Right |

Left Shift | << | Left to Right |

Right Shift | >> | Left to Right |

Less than | < | Left to Right |

Less than or Equal to | <= | Left to Right |

Greater than | > | Left to Right |

Greater than or Equal to | >= | Left to Right |

Equal to | == | Left to Right |

Not Equal to | != | Left to Right |

Bitwise AND | & | Left to Right |

Bitwise exclusive OR | ^ | Left to Right |

Bitwise OR | | | Left to Right |

Logical AND | && | Left to Right |

Logical OR | || | Left to Right |

Conditional Operator | ? : | Right to Left |

Assignment Operator | = , +=, -=, *=, /=, %=,^=, !=, <<=,>>= | Right to Left |

Comma | , | Right to Left |

## Recommended Posts

## Control Statement in C | if statement | switch case

What is control statement in c. What is if statement? how to work switch case statement in c programming language? What is loops? Types of loops?

## Loops in c | for loop | while loop | do while loop | c programming language

Welcome Guys.. What is loop and how many types of loops in c programming language. How loops work in c programming language.

## Array in c programming language

An Array is the list of finite number of elements of same data types. For Example: interger, string, float etc. An Array can be defined as the collection of the

## Break and Continue Statement in c

Break statement is usually used to terminate a case in the switch statement. In c programming language the continue statement works...

## Function in C | What is Functions?

Function like main(), printf() and scanf(), we have already come through. All c Programs made up of one or more function.