Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Monday, 13 June 2011

Using different arithmatic assignment operators in java program


class assignops
{
public static void main (String arg[])
{
int a=10,b=25,c=5,d=18,e=49;
a+=10;
b-=10;
c*=10;
d/=2;
e%=7;
System.out.println ("\n\t a = "+a);

System.out.println ("\n\t b = "+b);
System.out.println ("\n\t c = "+c);

System.out.println ("\n\t d = "+d);
System.out.println ("\n\t e = "+e);
}
}

Note:
          After execution you will observe following five changes
  1. Value of 'a' is increased by 10
  2. Value of 'b' is decreased by 10
  3. Value of 'c' is 50 (due to multiplying by 10)
  4. Value of 'd' is 9 (because we are dividing 'c' by 2)
  5. Value of 'e' is 0 (because 7 divides 49 properly)
 

    No comments:

    Post a Comment