switch case or if-elseif-else
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
정효 김
le 14 Juil 2020
Réponse apportée : Sai Sri Harsha Vallabhuni
le 14 Juil 2020
Hi guys. I was doing my assignment (Sierpenski triangle) and i solved it in two ways. switch case ans if-elseif-else. Which one do you think is more logical( less error)?
0 commentaires
Réponse acceptée
Sai Sri Harsha Vallabhuni
le 14 Juil 2020
In general, using a switch case gives better readability to the code. But, in your case, there isn't much difference as there are only three cases.
Coming to the more logical(less error), as both implement the same thing, there is no one better than the other in terms of logic.
Hope this helps.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Troubleshooting in Polyspace Products for Ada dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!