What is Arithmetic Operators and types with example

Arithmetic Operators:


following arithmetic operators Are

suppose variable A holds 10 and variable B holds 20 then:

Examples:

Operator         Description                                                                 Example
+              Adds two operands                                                       A + B will give 30
-           Subtracts second operand from the first                              A - B will give -10
*            Multiply both operands                                                    A * B will give 200
/            Divide numerator by denumerator                                       B / A will give 2
%         Modulus Operator                                                              B % A will give 0
++        Increment operator, increases integer value by one             A++ will give 11
--        Decrement operator, decreases integer value by one           A-- will give 9

Example: Write a program that perform arithmetic operator
  1.  #include <stdio.h>
  2.  
  3.  void main()
  4.  {
  5.          int a = 100;
  6.          int b = 3;
  7.          int c;
  8.  
  9.          c = a + b;
  10.          printf( "a + b = %dn", c );
  11.  
  12.          c = a - b;
  13.          printf( "a - b = %dn", c );
  14.  
  15.          /* multiplication performed before call to printf() */
  16.          printf( "a * b = %dn", a * b );
  17.  
  18.          c = a / b;
  19.          printf( "a / b = %dn", c );
  20.  
  21.          c = 100 % 3;
  22.          printf( "a % b = %dn", c );
  23.  }

Labels: