Which statement is preferred when there is a requirement to check multiple (more than 5) conditions in a program?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Which statement is preferred when there is a requirement to check multiple (more than 5) conditions in a program??

The options are- •nested if statement •if else statement •if statement •switch statement

20th Sep 2020, 4:49 AM
Utkarsh Goswami
Utkarsh Goswami - avatar
3 Answers
+ 2
It totally depends on what are the conditions you want to evaluate.
20th Sep 2020, 5:09 AM
Arsenic
Arsenic - avatar
+ 2
It depends on the conditions but writing more than a 5 if statement is horrible and must be avoided unless absolutely necessary, you should try to somehow check them in a loop, otherwise I guess switch would be the best option
20th Sep 2020, 5:37 AM
Bagon
Bagon - avatar
+ 2
According to me SWITCH is more preferable,but it will only be when there is any printing statement about the choice
28th Feb 2021, 12:16 PM
Muskan Rawat
Muskan Rawat - avatar