can you explain whats going on line by line and what the ans
can you explain whats going on line by line and what the answers are? thanks!!
Write down the values for all variables appearing in each statement. (this one is tricky) int main () {int x, y, z; float a, b; a = 2.5, b = 3.14; x = 3; y = 5.3; z = 2; x y z x += y + a * z-b; x z += (x == y); z x == (a = b); x return 0;}Solution
x = 3; y =5.3; z=2;
Because of assignment x is 3, y is 5.3 and z is 2.
x += y + a*z-b;
First a*z will be executed which will give 5 so 5.3+5-3.14 will give 7.16. x += 7.16 will give x = 10.16. So x= 10.16.
z += (x==y)
(x==y) will return 1 if x and y are equal and 0 otherwise. Here x is not equal to y. so this will be 0. So z+= 0 will make z unchanged at 2. So z=2.
x == (a=b)
First a=b is executed this will make a as 3.14 and the statement (a=b) will return 3.14. x == 3.14 will compare the values of x and 3.14 but will not make any changes to value of x. So x= 10.16.
