Computer Science, asked by bhamaresamarthoxuqkz, 1 year ago

Identify valid and invalid expressions from following switch statements: a. switch(1+2+23) b. switch(a+b+c) c. switch(1*2+3%4) d. switch(ab+cd)

Answers

Answered by dilipkumarprinp4e6xm
7
b.switch(a+b+c)is valid
others are invalid



samubhamare: Can you specify the reason
dilipkumarprinp4e6xm: becaz in switch u cant give integers
Answered by Secondman
9

Answer: A and C are valid whereas B and D are valid under certain conditions.

The quantity value in switch case statements should be one among the following: integer or character or enumeration.

Thus, unless the variables in B and D are of the above types, the switch statement becomes invalid.

On the other hand, A and C quantity values are integers and thus, the switch statement is valid in these cases.

Similar questions