Skip to content

Commit 5c77c56

Browse files
authored
Create 3. Switch Questions.txt
1 parent ed3ca30 commit 5c77c56

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
*******************************
2+
WEEK-3 QUIZ: Switch Questions
3+
*******************************
4+
5+
6+
--------------------------------------------------------------------------------------------------------------------------------------------------------
7+
. . .
8+
switch(i)
9+
{
10+
11+
case 1: printf(“case 1 \n”); break;
12+
case 2: printf(“case 2 \n”);
13+
case 3: printf(“case 3 \n”);break;
14+
15+
default: printf(“default case \n”);
16+
17+
};
18+
19+
20+
>>
21+
22+
1. If i starts off as 1 then printf will print:
23+
24+
I - case 1 <---------------------- [ANSWER]
25+
II - case 1 case 2
26+
III - will not print
27+
IV - default case
28+
29+
--------------------------------------------------------------------------------------------------------------------------------------------------------
30+
2. If i starts out as 15 the printf will print:
31+
32+
I - case 15
33+
II - case 1
34+
III - will not print
35+
IV - default case <---------------------- [ANSWER]
36+
37+
--------------------------------------------------------------------------------------------------------------------------------------------------------
38+
3. If i starts out as 2 the printf will print:
39+
40+
I - case 2
41+
II - case 2 case 3 <---------------------- [ANSWER]
42+
III - will not print
43+
IV - default case
44+
45+
--------------------------------------------------------------------------------------------------------------------------------------------------------
46+
47+
48+
49+
~ TSG405, 2021

0 commit comments

Comments
 (0)