Question: for ( int i = 0 ; i < 3 ; i + + ) { int y = 3 ; if ( y =

for(int i =0; i <3; i++){
int y =3;
if(y ==3){
int z =5;
cout << "Value of z is: "<< z << endl;
cout << "Value of y is: "<< y << endl;
}
cout << "Value of y outside the if-statement is: "<< y << endl;
}
cout << "Trying to access y outside if and for-block, value of y: "<< y << endl;
4.1 Can this snippet print the value of z?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!