# Operators

## Assignment Operator (=)

Assignment operator is used to assign values to the variables

**Syntax**:

*variable_name=expression;*

Example

x=a;

x=(a+b)/c;

### Multiple Assignment

int x=y=z=6;The variables will always be on the left hand side of the operator and the value to be assigned to the variable will be on the right side.

## Arithmetic Operators

- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%)
- Increment (++)
- Decrement (--)

Arithmetic operators are used to carry out any mathematical operations in the program.

### Addition Operator (+)

**Syntax**:

*operand + operand*

Examples

a+b;

5+6;

a+b;

5+6;

### Subtraction Operator (-)

**Syntax**:

*operand - operand*

Examples

a-b;

10-6;

a-b;

10-6;

### Multiplication Operator (*)

**Syntax**:

*operand * operand*

Examples

a*b;

5*6;

a*b;

5*6;

### Division Operator (/)

**Syntax**:

*operand / operand*

Examples

a/b;

51/3;

a/b;

51/3;

23/4 will give 5 as output if a and b are of integer type.

Try the code below.

int a=23;b=5; printf("The division is %d",a/b); float div; div=a/b; printf("The division is %d",div);

### Modulus Operator (%)

**Syntax**:

*operand % operand*

a%b;

6%3;

6%3;

Modulus Operator is used to find the remainder of the division of the integers.

Examples

13%2 will give remainder as 1

15%3 will give remainder 0

15%2 will give remainder 1

Try This

```
```#include<stdio.h>
int main()
{
int a,b;
printf("Enter 2 integers\n");
scanf("%d%d",&a,&b);
printf("The sum is %d\n",a+b);
printf("The difference is %d\n",a-b);
printf("The product is %d\n",a*b);
printf("The division is %d\n",a/b);
printf("The remainder is %d\n",a%b);
return 0;
}

Try This

```
```#include<stdio.h>
int main()
{
int a=40, b=3, result;
result=(((a*b)+30)/15)%2;
printf("The result is %d",result);
return 0;
}