posted 5 years ago

hi

i have a doubt regarding below program

class Prog

{

public static void main(String[] args)

{

int a,b,c,d;

a=b=c=d=100;

a+=b*=c/=d%=20;

System.out.println("a......."+a+"b.........."+b+"c.........."+c+"d........."+d);

}

}

i got a=1320,b=1210,c=11,d=10

so, what is the values of a,b,c,d and please explain the a+=b*=c/=d%=20; equation assignment process

i have a doubt regarding below program

class Prog

{

public static void main(String[] args)

{

int a,b,c,d;

a=b=c=d=100;

a+=b*=c/=d%=20;

System.out.println("a......."+a+"b.........."+b+"c.........."+c+"d........."+d);

}

}

i got a=1320,b=1210,c=11,d=10

so, what is the values of a,b,c,d and please explain the a+=b*=c/=d%=20; equation assignment process

posted 5 years ago

It doesn't look like you actually ran this code, did you? You can break this down into its equivalent:

Note that evaluation starts from the right and proceeds to the left. What you have is fundamentally a series of assignment statements so the order of precedence of math operators does not come into play here.

Harivenkatesh Polnati wrote:

i got a=1320,b=1210,c=11,d=10

so, what is the values of a,b,c,d and please explain the a+=b*=c/=d%=20; equation assignment process

It doesn't look like you actually ran this code, did you? You can break this down into its equivalent:

Note that evaluation starts from the right and proceeds to the left. What you have is fundamentally a series of assignment statements so the order of precedence of math operators does not come into play here.

*Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.*— Junilu

[How to Ask Questions] [How to Answer Questions]