switch case or if-elseif-else
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Sai Sri Harsha Vallabhuni
2020년 7월 14일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Troubleshooting in Polyspace Products for Ada에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!