Based on the dangling-else discussion in Exercise ANS: , modify the given code to produce the output

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 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.
#####
$$$$$
&&&&&

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Visual C# How to Program

ISBN: 978-0134601540

6th edition

Authors: Paul J. Deitel, Harvey Deitel

Question Posted: