What are the values of x y and z after executing the followi


What are the values of x, y and z after executing the following code? x = 4; y = 6; z = 2; if (x == 4) if (y == 7) x = 5; else if (y >= 6) z = 5; What is the output after executing the following code? int a = 10, b = 6; ctr = 0; if (a! = a|| a == a_ cout

Solution

Answer: 3)

X=4

Y=6

Z=5

If( )

If()

Statement;

Else If()

Statement;

Is same as

If( )

{

If()

Statement;

Else {

If()

Statement;

}

}

Answer : 4)

3 9 13 is the output

Explaination :

If( statement1 || statement2) In this if anyone of statements is true then if() is executed

Soo first one executes

Then... CTR=0 initially.. While (CTR<3) { CTR++; B++; } Means loop executes 3 times

Soo CTR=3 b=9

Do while(); Here after printing CTR+a=3+10=13 value it checks for the condition while(CTR<3) Soo false loop terminated

 What are the values of x, y and z after executing the following code? x = 4; y = 6; z = 2; if (x == 4) if (y == 7) x = 5; else if (y >= 6) z = 5; What is th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site