Arithmetic Operators:

Arithmetic operators means do the all arithmetic operations like as addition, subtraction, multiplication , division, modules etc.
All the operators have almost the same meaning as in other languages. Both unary and binary operations are available in C language. Unary operations operate on a singe operand, therefore the number 5 when operated by unary – will have the value –5.

Arithmetic Operators:

__________________________________________________________

Operator                            Meaning _______________________________________

__________________________________________________________
–                                             Subtraction or Unary Minus

__________________________________________________________
*                                                Multiplication

__________________________________________________________
/                                                     Division

__________________________________________________________
%                                                Modulus Operator
__________________________________________________________

Example:
void main()  // the start of the program
{
int numb1, num2, sum, sub, mul, div, mod;           //declaration of variables
scanf (“%d %d”, &num1, &num2);                      //inputs the operands

sum = num1+num2;    //addition and storing in sum.
printf(“\n Thu sum is = %d”, sum);            //display the output
sub = num1-num2;                                    //subtraction and storing in sub.
printf(“\n Thu difference is = %d”, sub);      //display the output
mul = num1*num2;                                    //multiplication storing in mul.
printf(“\n Thu product is = %d”, mul);              //display the output
div = num1/num2;     //division storing in div.
printf(“\n Thu division is = %d”, div);
//display the output
mod = num1%num2;                                    //modulus and storing in mod.
printf(“\n Thu modulus is = %d”, mod);              //display the output
}

Integer Arithmetic

When an arithmetic operation is performed on two whole numbers or integers than such an operation is called as integer arithmetic.
It always gives an integer as the result.
Let x = 20 and y = 5 be 2 integer numbers.
Then the integer operation leads to the following results.
x+y=27
x–y=15
x*y=100
x%y=0
x/y=4
In integer division the fractional part is truncated

What is Floating point arithmetic

When an arithmetic operation is preformed on two real numbers or fraction numbers such an operation is called floating point
arithmetic.
The floating point results can be truncated according to the properties requirement.
The remainder operator is not applicable for floating point arithmeticoperands.
Let x=14.0 and y=4.0
then
x+y=18.0
x–y=10.0
x*y=56.0
x/y=3.50

what is Mixed mode arithmetic

When one of the operand is real and other is an integer and if the arithmetic operation is carried out on these 2 operands then it is
called as mixed mode arithmetic.
If anyone operand is of real type then the result will always be real thus 15/10.0 = 1.5

2. Relational Operators

Often it is required to compare the relationship between operands and bring out a decision and program accordingly. This is when
The relational operator comes into picture.
C supports the following relational operators.

__________________________

Operator                          Meaning
_______________________________________
<                                 is less than
<=                               isless than or equal to
is greater than
>=                               is greater than or equal to
==                                  is equal to

!=                                   is not equal to
________________________________________

It is required to compare the marks of 2 students, salary of 2 persons, we can compare them using relational operators.

A simple relational expression contains only one relational operator and takes the following form.

Where exp1 and exp2 are expressions, which may be simple constants, variables or combination of them. Given below is a list of
Examples of relational expressions and evaluated values.
6.5 <= 25 TRUE
-65 > 0 FALSE
10 < 7 + 5 TRUE

Relational expressions are used in decision making statements of C language such as if, while and for statements to decide
the course of action of a running program.

3. Logical Operators

C has the following logical operators, they compare or evaluate logical and relational expressions.

__________________________________________

Operator                            Meanings
__________________________________________
&&                     Logical AND
||                                       Logical OR
!                                       Logical NOT

___________________________________________

Logical AND (& &) :

This operator is used to evaluate 2 conditions or expressions with relational operators simultaneously. If both the expressions to the left and to the right of the logical operator is true then the whole compound expression is true.
Example:      a>b && x==10
The expression to the left is a > b and that on the right is x == 10 the whole expression is true only if both expressions are true i.e., if a is greater than b and x is equal to 10.

Logical OR (||) :

The logical OR is used to combine 2 expressions or the condition evaluates to true if any one of the 2 expressions is true.
Example :      a

The expression evaluates to true if any one of them is true or if both of them are true. It evaluates to true if a is less than either m or n and when a is less than both m and n.

Logical NOT (!) :

The logical not operator takes single expression and evaluates to true if the expression is false and evaluates to false if the expression is true. In other words it just reverses the value of the expression.
For example:
! (x >= y) the NOT expression evaluates to true only if the value of x is neither greater than or equal to y

4. Assignment Operators

The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression.
Example :   x = a + b
Here the value of a + b is evaluated and substituted to the variable x.

In addition, C has a set of shorthand assignment operators of the form.
Varoper = exp;

Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator

Example :
x + = 1 is same as x = x + 1
The commonly used shorthand assignment operators are as follows

what is Shorthand assignment operators

assignment operator  shorthand operator

a = a + 1                          a += 1
a = a – 1                            a -= 1
a = a * (n+1)                a *= (n+1)
a = a / (n+1)                 a /= (n+1)
a = a % b                       a %= b
Example for using shorthand assignment operator

#define N 100                      //creates a variable N with constant value 100
#define A 2                         //creates a variable A with constant value 2
main()                               //start of the program
{
int a;                              //variable a declaration
a = A;                              //assigns value 2 to a
while (a < N)                       //while value of a is less than N
{                                   //evaluate or do the following
printf(“%d \n”,a);                    //print the current value of a
a *= a;                             //shorthand form of a = a * a
//end of the loop
}                                   //end of the program
Output :
2
4
16

c operators examples,c operators precedence, c operators pdf, c operators ppt, c bitwise operators, c operators associativity, c operators and expressions, c operators are evaluated from left to right, c language operators, types of operators in c programming, different types of operators in c, various operators in c, assignment operators in c, bitwise and, = operator in c, unary operator in c, Searches related to c operators precedence, order of precedence of operators, c++ not equal,operator associativity and precedence in c, c++ order of precedence,operator precedence in c++ example, c++ operator associativity, *= c++ operator,c++ operator =, relational operator in c, conditional operator in c example,ternary operator in c example, conditional operator in c programming, conditional operator in c with example, unary operators in c language,increment and decrement operators in c programming, conditional operator example in c,relational operators in c with examples,  bitwise operator program in c, conditional statements in c, programming, conditional statement in c with example,Explain Operators in c programming,  Arithmetic operator, Relational Operators, Logical Operators, Assignment Operators, Increments and Decrement Operators , Conditional Operators, Bit wise Operators , Special Operators