Arithmetic Operators in C Language

This “Arithmetic Operators in C” post providing information about list of arithmetic operators in c, priority of these operators, different between division and remainder operator with suitable examples.


 

Arithmetic operators: 

  • These operators are used to perform Arithmetic operations on data.
  • The operators are + ,  –  , * , / , %

 

  • (/ , %), both operators performs division operation on data.
  • ” / ” operators return “Quotient” as a result.
  • “%” returns “Remainder” as a result.
  • for example….
         5/2 = 2
            5%2 = 1

 

  • In arithmetic operators +,- having equal priority. Hence if any expression contains these two operators, evaluates from left to right.
    5+3-2 –> 6
    5-2+3 –> 6

 

  • Remaining three operator (*,/,%) having equal priority, but which higher prior than (+,-).
  • for example…. 5 + 3 * 2 —> 11

 

  • ( ) having higher prior than all the arithmetic operators.
    for example….(5 + 3) * 2 —> 16

 

#include<stdio.h>
main()
{
int a=3,b=5,c=2,d=7,e;
clrscr();
e = d-b%(a+c)-d+(b/a)-c+a-b;
printf(“%d”,e);
}

Share this