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;
}
#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
}
Comments
Leave a comment