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
a if y 8 if x 5 ConsoleWriteLine else ConsoleWriteLine ConsoleWriteLine Conso... View full answer
Get step-by-step solutions from verified subject matter experts
