predict output...pls make me understand
Attachments:

Answers
Answered by
1
Its switch case.
The variable 'k' is called the case variable and its value decides which case will be executed.
for k=1:
B
C
D
case 1 will be executed.since there is nothing written under case 1 so no output for this.but further statements will be executed since no break statement.
for k=2
case 2 will be executed.
output:B
C
D
C and D are also printed as no break statements are used.
k=33:
output:C
D
as the print statement is used in this case.
for k=10
no case 10 is present so cursor will directly reach the default case.
output:D
done.
The variable 'k' is called the case variable and its value decides which case will be executed.
for k=1:
B
C
D
case 1 will be executed.since there is nothing written under case 1 so no output for this.but further statements will be executed since no break statement.
for k=2
case 2 will be executed.
output:B
C
D
C and D are also printed as no break statements are used.
k=33:
output:C
D
as the print statement is used in this case.
for k=10
no case 10 is present so cursor will directly reach the default case.
output:D
done.
Similar questions