Math, asked by laxmikarua07, 8 months ago

.4. (a) Write the output of the following code snippet:
int a = 5, b = 2;
int c = a/b;
double d = (double) a/b;
int e = (double) a/b;
System.out.println( C+" "+d+""+e);​

Answers

Answered by ItzDeadDeal
9

Answer:

Here is your Answer:

this code segment contains prefix and postfix operator so first u have to understand the working of each

In prefix (++a or --a) here the value of the variable is incremented or decremented first and the value is calculated in expression.

In postfix (a-- or a++) here the value of the variable is incremented or decremented after the calculation of expression. meaning the expression is executed with the previous value and after execution of expression is completed then for the next expression the value of the variable is incremented or decremented.

int a = 34;

int b = 21;

int c = a++ + ++b;  (34+22=56)

int d = --a + --b + c--; (34+21+56=111)

int e = a + ++b + ++c + d--; (34+22+56+111=223)

int f = --a + b-- + --c - d++; (33+22+55-110=0)

int sum = a + b + c + d + e + f; (33+21+55+111+223+0=443)

System.out.println("sum = " + sum); } }

so the output is 443

Similar questions