Answer to Question #287333 in C++ for Abebe

Question #287333

If the originally x=2 ,y=1 and z=1, what are the value of x, y, z after executing the


following code?


Switch(x)


{


case 0 : x = 2;


y =3;


case 1 : x =4;


Default:


y = 3;


x = 1;


}

1
Expert's answer
2022-01-13T09:39:26-0500
#include<iostream>

using namespace std;

int main()
{
	int x=2;
	int y=1;
	int z=1;
	switch(x)
	{
		case 0:x=2;
			y=3;
		case 1:x=4;
		default:
			y=3;
			x=1;
	}
	cout<<"x = "<<x;//1
	cout<<"\ny = "<<y;//3
	cout<<"\nz = "<<z;//1
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment