0
Can you find the error, please, and tell me how to fix it
2 Answers
+ 3
Define variable answer out of switch.
https://www.sololearn.com/compiler-playground/cACVsrdDTDTk
+ 1
If you must define and use a variable in `switch` labels, then wrap the label body inside curly brackets.
However, in your case, it would be simpler to define variable <result> once before the `switch` and then just use it inside the labels.
switch( math )
{
case '+':
{
// code here ...
}
}