int x=1; int y=x%x*x/x; | Sololearn: Learn to code for FREE!

+2

# int x=1; int y=x%x*x/x;

Please help me how to get the value of y and what will be the correct answer.

8/5/2019 4:29:06 PM

Khushi Puri

+3

So it means the correct answer is 0 Please correct me if I am wrong

+3

But the data type of y is int so please tell why the answer will be 0.0 ?? Thanks for replying

+2

I think the answer should be 0. Please tell me the reason for 0.0 as the correct answer

+2

Thanks

+1

Because %, * and / have the same operator precedence, the operations will be performed from left to right. x%x*x/x =0*x/x =0/x =0

+1

int x=5 ; int y=x; int y= x++ + x++ - ++x; help me for this operation?

+1

thankx Khushi for helping , I had done operator concept but sometime it make lots of confusion ... but again I will definatly work on this

0

Hint: y = 1 % 1 * 1 / 1 The remainder of 1/1 multiplied by 1/1

0

0.0

0

the division gives you a float. if it were floor division meaning // it wouldn't be.

0

Shubham the answer of your question is y=5+6-7=4. Learn about pre and post increment operators.I hope you understand