+ 7
In control structure case what is the purpose of default in C++
4 Answers
+ 8
My answer is the keyword gives the switch.. Case construct a way to take an action if the value of the switch variable doesnot match with any of the case construct, no break statement is necessary after default case, since the control is already at the end of switch.. Case construct. The default is optional incase of switch.. Case statement
+ 9
default in both C and CPP allows for code execution when all the above cases/conditioned are false/ not satisfied.
+ 8
Oh you like your own answer best?
+ 2
If all other cases didn't match do something else
Example
You made calculator with switch case for operator
Somebody entered $, which fails all operators so you covert it to + (or any other) in default