What is the defference between else and default blocks? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the defference between else and default blocks?

C++

13th Mar 2021, 9:34 AM
Manuprasad Kp
Manuprasad Kp - avatar
3 Answers
+ 2
switch operator has no “else”. It has cases and the default case that is used when no other cases match
13th Mar 2021, 9:36 AM
Sveta Z.
Sveta Z. - avatar
+ 1
Manuprasad Kp else is used with if condition. if(true) { //will execute if true } else { //will execute when if case failed } default is used in switch case. If any case will not satisfy the condition then default case will be execute.
13th Mar 2021, 10:35 AM
A͢J
A͢J - avatar
0
else is for if statement. default is for switch. They're usage is basically the same, but they're used in different terms.
13th Mar 2021, 9:41 AM
你知道規則,我也是
你知道規則,我也是 - avatar