Q:

Rewrite the following switch statement as one nested if-else statement (elseif clauses may be used). Assume that there is a variable letter and that it has been initialized

0

Rewrite the following switch statement as one nested if-else statement (elseif clauses may be used). Assume that there is a variable letter and that it has been initialized.

switch letter

case 'x'

disp('Hello')

case {'y', 'Y'}

disp('Yes')

case 'Q'

disp('Quit')

otherwise

disp('Error')

end

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch4Ex23.m

letter = char(randi([97,122]));

if letter == 'x'

 disp('Hello')

elseif letter == 'y' || letter == 'Y'

 disp('Yes')

elseif letter == 'Q'

 disp('Quit')

else

 disp('Error')

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now