+ 1

In the switch stament,why is there a default statement at the end?

14th Nov 2019, 2:37 PM
Weno Ndum Billy Hans
6 Answers
+ 5
If no case executes then default will execute.... It will deal with no case match condition
14th Nov 2019, 2:50 PM
Saurabh B
Saurabh B - avatar
+ 1
Yeah just went over it...its clear now...thanks
14th Nov 2019, 2:47 PM
Weno Ndum Billy Hans
+ 1
cases are basically if/else ifs and the default statement is basically an else statement. you also dont NEED a default statement if you cant find a use for one
14th Nov 2019, 8:12 PM
꧁àŒș Jenspi àŒ»ê§‚
꧁àŒș Jenspi àŒ»ê§‚ - avatar
0
Ok so what the function of the default statement?
14th Nov 2019, 2:45 PM
Weno Ndum Billy Hans
0
The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.
14th Nov 2019, 3:03 PM
HARITEJA KODURI
HARITEJA KODURI - avatar
0
If no one of the cases is true, the object inside the default statement will be executed.
16th Nov 2019, 12:31 PM
Eduardo Cavalcante
Eduardo Cavalcante - avatar