Question: Based on the dangling-else discussion in Exercise ANS: , state the output for each of the following code snippets when x is 9 and y

Based on the dangling-else discussion in Exercise ANS: , state the output for each of the following code snippets when x is 9 and y is 11 and when x is 11 and y is 9. We eliminated the indentation from the following code to make the problem more challenging.
a) if (x < 10)
if (y > 10)
Console.WriteLine("*****");
else
Console.WriteLine("#####");
Console.WriteLine("$$$$$");

b) if (x < 10)
{
if (y > 10)
Console.WriteLine("*****");
}
else
{
Console.WriteLine("#####");
Console.WriteLine("$$$$$");
}

Step by Step Solution

3.51 Rating (175 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a When x is 9 and y ... View full answer

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 Visual C How Program Questions!