What arc the values of x y and z after the following stateme
What arc the values of x. y. and z after the following statements are executed? int z = 35, x = 50, y = 50; if (x > = y) {z = x + 10; x = x-y;} else if (x ! = y) {x = y; z -= y; y =z + x;} else {z= y + 10; y += x;}
Solution
main.cpp
#include<iostream>
using namespace std;
int main()
{
int x = 50, y=50, z=35;
if(x>=y)
{
z=x+10;
x=x-y;
}
else if(x!=y)
{
x=y;
z-=y;
y=z+x;
}
else{
z=y+10;
y+=x;
}
cout <<\"x=\"<< x<<\"y=\"<<y<<\"z=\"<<z;
return 0;
}
Output:
