Wednesday, December 5, 2012 #

integer arithmetic

Integer arithmetic
 When both operands are integer then the arithmetic operation with these operand is called integer arithmetic.

    Let us take two variable a and b. The value of a =17 and b=4 then the result of these operation are –

 Expression                          result
a+b                                          21
a-b                                          13
a*b                                          68
a/b                                           4
a%b                                         1

    after division operation the decimal   part will be truncated and result is only   integer part of quotient .after  modulus operation the result will be remainder part of integer division.

   It is necessary  fo division and modulus operation that second operand must be nonzero.

1.Program to understand the integer   arithmetic operatin .

Void main( )
Int a=17,b =4;
Printf(“after addition :%d\n”,a+b);
Printf(“after subtraction :%d\n”a-b);
Printf(‘after division :%d\n”a/b);
Printf(“after modulus :%d\n”,a %d);
After addition :21
After subtraction :13
After multiplication :68
 After division:4
After modulus:1

posted @ Wednesday, December 5, 2012 4:42 PM | Feedback (0)

Copyright © Afsana Bano

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski

Advertisements at