### C Operators

Operators in C Language is that An Operator performs operations on data value stored in variable, constants and array etc. C Operators take one or more operand as input and give a result after applying operation over them. Like in "a+b", 'a' and 'b' are the operands and '+' is an operator which performs the add operation on 'a' and 'b' operands. Operators in C Language have many types such as Arithmetic Operators, Relational Operators, Logical Operators, Assignment Operators, Bitwise Operators, and Conditional Operator. Unary Operators In C is ++ and -- called as unary operator.

Eitworld.com provides the simple learning on C Operators with examples without any cost.

- An Operator performs operations on data value stored in variable, constants and array etc.
- Operators take one or more operand as input and give a result after applying operation over them. Like in "a+b", 'a' and 'b' are the operands and '+' is an operator which performs the add operation on 'a' and 'b' operands.
- C provides reach set of operators which are as follows:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Assignment Operators
- Bitwise Operators
- Conditional Operator

Let us discuss the C operators in detail:

#### Arithmetic Operators

- Arithmetic operators are the operators which perform the mathematical operation between two operands.
- We can classified the Arithmetic Operators in two categories:
- Binary Operators
- Unary Operators

##### Binary Operators

- Binary Operators are those operators are those arithmetic operators which take two operands to perform operation.
- Here is the list of Binary operators supported by the C language:

##### Unary Operators

- Unary Operators are those operand which takes only one operand to perform operation.
- Here is the list of the Unary Arithmetic operators supported by the C language:
- Here is a simple example which shows the use of Arithmetic operators in C language as follows:

##### Example

#include<conio.h>

int main()

{

int a=4,b=2;

clrscr();

printf("\nAddition:%d",(a+b));

printf("\nSubtraction:%d",(a-b));

printf("\nMultiplication:%d",(a*b));

printf("\nDivison:%d",(a/b));

printf("\nModular Division:%d",(a%b));

printf("\nIncrement of a:%d",(++a));

printf("\nDecrement of b:%d",(--b));

getch();

return 0;

}

##### output

The output of the above program is as follows:

Subtraction: 2

Multiplication: 8

Division: 2

Modular Division: 0

Increment of a:5

Decrement of b:1

#### Relational operators

- Relational operators are used for the comparison between two values.
- Here is table containing the list of several relational operators:
- Here is an example of using relational operator in C language:

##### Example

```
#include<stdio.h>
```

#include<conio.h>

int main()

{

printf("\n4>3:%d",(4>3));

printf("\n4<3:%d",(4<3));

printf("\n4<=4:%d",(4<=4));

printf("\n2>=3:%d",(2>=3));

printf("\n2==2:%d",(2==2));

printf("\n2!=2:%d",(2!=2));

getch();

return 0;

}

##### output

The output of the above program is as follows:

4<3:0

4<=4:1

2>=3:0

2==2:1

2!=2:0

#### Logical Operators

- Logical operators check the logical relationship between the two expressions.
- Here is the table containing the list of several Logical Operators :
- Logical AND (&&) operator will return true value (1) if both the expressions are true otherwise it will return false value (0).
- Logical OR (||) operator will return true value (1) when at least one of the expression is true otherwise it will return false value (0).
- Logical NOT (!) operator will return true value(1) when condition is false and if condition is true it will return false value (0).
- Here is an example of using relational operator in C language:

##### Example

```
#include<stdio.h>
```

#include<conio.h>

int main()

{

printf("\n2>1 && 3>2:%d",(2>1&&3>2));

printf("\n2<1||2>3:%d",(2<1||2>3));

printf("\n2!=2:%d",(2!=2));

getch();

return 0;

}

##### output

The output of the above program is as follows:

2<1 || 2>3:0

2 !=2:0

#### Assignment Operators

- Assignment operators are used to assign the value in variables, arrays or constant.
- Here is a list of Assignment operators in the given table:
- Here is an example of using assignment operator in C language:

##### Example

```
#include<stdio.h>
```

#include<conio.h>

int main()

{

int x = 10;

int y = 5;

x = y;/*simple assignment*/

printf("\nResult of x=y:%d",x);

x += y;/*addition and assignment*/

printf("\nResult of x+=y:%d",x);

x -= y;/*subtraction and assignment*/

printf("\nResult of x-=y:%d",x);

x*=y;/*multiplication and assignment*/

printf("\nResult of x*=y:%d",x);

x /= y;/*division and assignment*/

printf("\nResult of x/=y:%d",x);

x %= y;/*modulus and assignment*/

printf("\nResult of x%=y:%d",x);

getch();

return 0;

}

##### output

The output of the above program is as follows:

Result of x+=y:x=10

Result of x-=y:x=5

Result of x*=y:x=25

Result of x/=y:x=5

Result of x%=y:x=0