Question: Given the following program segment that uses a switch statement, convert it into a segment of code that uses a multi-alternative if statement. Assume that
Given the following program segment that uses a switch statement, convert it into a segment of code that uses a multi-alternative if statement. Assume that val is declared to be an int. You do not need to write an entire C# program, just a segment of code containing a multi-alternative if statement that replicates the behavior of the code below containing a switch statement. switch(2*val + 1) { } case 3: Console.WriteLine("First"); break; case 4: case 1: Console.WriteLine("Second"); break; default: Console.WriteLine("Third"); break
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
