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
a When x is 9 and y ... View full answer
Get step-by-step solutions from verified subject matter experts
