integer arithmetic

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

    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 .

Include<stdio.h>
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);
}
Output:
After addition :21
After subtraction :13
After multiplication :68
 After division:4
After modulus:1
 
 
 
 
 
 
 
 

Print | posted on Wednesday, December 5, 2012 4:42 PM


Advertisements at BlogUnlimited.com

Feedback

No comments posted yet.

Your comment:





 
Please add 5 and 1 and type the answer here:

Copyright © Afsana Bano

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski

Advertisements at BlogUnlimited.com