Question: Based on the dangling-else discussion in Exercise ANS: , modify the given code to produce the output shown in each part of the problem. Use

Based on the dangling-else discussion in Exercise ANS: , modify the given code to produce the output shown in each part of the problem. Use proper indentation techniques. You must not make any additional changes other than inserting braces. We eliminated the indentation from the following code to make the problem more challenging. [It’s possible that no modification is necessary.]
if (y == 8)
if (x == 5)
Console.WriteLine("@@@@@");
else
Console.WriteLine("#####");
Console.WriteLine("$$$$$");
Console.WriteLine("&&&&&");
a) Assuming that x = 5 and y = 8, the following output is produced:
@@@@@
$$$$$
&&&&&

b) Assuming that x = 5 and y = 8, the following output is produced:
@@@@@

c) Assuming that x = 5 and y = 8, the following output is produced:
@@@@@
&&&&&
d) Assuming that x = 5 and y = 7, the following output is produced.
#####
$$$$$
&&&&&

Step by Step Solution

3.35 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a if y 8 if x 5 ConsoleWriteLine else ConsoleWriteLine ConsoleWriteLine Conso... 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!