0
Why switch case better then if else?
Quote :"You can achieve the same result with multiple if...else statements, but the switch statement is more effective in such situations." Why is it more effective??
3 Respuestas
+ 6
switch statement is faster to execute than the if-else-if ladder. This is due to the compiler's ability to optimise the switch statement. In the case of the if-else-if ladder, the code must process each if statement in the order determined by the programmer. However, because each case within a switch statement does not rely on earlier cases, the compiler is able to re-order the testing in such a way as to provide the fastest execution.
+ 1
Perfect thank you!!!
0
welcome ;)