when we use switch statement | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

when we use switch statement

13th Jun 2016, 9:55 AM
Shivam Sharma
Shivam Sharma - avatar
14 Respostas
+ 2
It is a kind of alternative to if-else if-else loop. Excetion is, you choose option and then break or continue. Cheers Happy Coding
13th Jun 2016, 10:00 AM
Zahid Ali
Zahid Ali - avatar
+ 1
basically when more check and validate situations are present like going through all the days in week and months of a year we use switch..
13th Jun 2016, 10:42 AM
N.Ramakrishnan
N.Ramakrishnan - avatar
+ 1
when you have too many conditions to handle.... Instead of using so many if statements we use switch.....
13th Jun 2016, 1:54 PM
Utpal Kumar
Utpal Kumar - avatar
+ 1
if there is more conditions,to decrease coding we can't use if else if else repetitively so to make it properly indented we use switch
13th Jun 2016, 4:50 PM
DJ Shiva & DJ Baba Shiv-Shekhar
DJ Shiva & DJ Baba Shiv-Shekhar - avatar
+ 1
when we hav many conditions and want to perform any one condition for single time by taking the input from the user and to perform that specified task.
15th Jun 2016, 5:13 AM
anirudh
anirudh - avatar
0
If We have more choice then we use the switch statementā€¦simpleā€¦
14th Jun 2016, 7:27 AM
Prasanna Udpm
Prasanna Udpm - avatar
0
same (if statement ) when you want do condition
18th Jun 2016, 2:43 PM
raees
0
ya we use it according to tha problem
19th Jun 2016, 7:12 PM
Iman Ali
Iman Ali - avatar
0
Yeah it's simple!
19th Jun 2016, 7:20 PM
Utpal Kumar
Utpal Kumar - avatar
0
for conditional purpose
22nd Jun 2016, 4:19 PM
gandhiyash
0
It's an alternative for so many if statements.....
22nd Jun 2016, 4:38 PM
Utpal Kumar
Utpal Kumar - avatar
0
Most of the time when there are predefined and know set of possible (or needed) values or there're lot of if statements which slows down the execution of program
1st Jul 2016, 9:15 PM
Azriel Gridfen
Azriel Gridfen - avatar
0
in menu driven problems
13th Jul 2016, 6:24 PM
Bikram Keshari Maharana
Bikram Keshari Maharana - avatar
0
It's basically for a menu driven type programs ! Hope u get that ;)
28th Jun 2017, 3:43 PM
ismath
ismath - avatar