What will be the output of the following C# code?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19SA
icon
Related questions
Question
What will be the output of the following C# code?
1.
static void Main(string[] args)
2.
{
int i = 2, j
3, k = 4;
3.
4.
switch (i +j
k)
5.
{
6.
case 0: case 2: case 4:
7.
++i;
8.
k +=
j;
9.
break;
10.
case 1: case 3: case 5 :
11.
-i;
12.
k -=
j;
13.
break;
14.
default:
15.
i +=
j;
16.
break;
17.
18.
Console.Writeline(i + "\n" + j + "\n" + k);
Console. ReadLine();
19.
20. }
a) 131
b) 2 34
c) 5 34
d) Compile time error
Transcribed Image Text:What will be the output of the following C# code? 1. static void Main(string[] args) 2. { int i = 2, j 3, k = 4; 3. 4. switch (i +j k) 5. { 6. case 0: case 2: case 4: 7. ++i; 8. k += j; 9. break; 10. case 1: case 3: case 5 : 11. -i; 12. k -= j; 13. break; 14. default: 15. i += j; 16. break; 17. 18. Console.Writeline(i + "\n" + j + "\n" + k); Console. ReadLine(); 19. 20. } a) 131 b) 2 34 c) 5 34 d) Compile time error
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning