what is the different between if-else and switch statment
(other than syntax)
Answer Posted / sujith
I would like to answer this question from a compiler
perspective. When we have if else or if else tree, we have
many compare instructions ( assembly generated by compiler)
where as switch has only one compare and jump instruction.
If the idea is to does something after comparing the values,
it is always better to go with the switch case than if else
tree.
I would appreciate analyzing the assembly code, with the
same source, with if else tree and switch case statements.
| Is This Answer Correct ? | 58 Yes | 33 No |
Post New Answer View All Answers
what type of questions arrive in interview over c programming?
What are data types in c language?
Can main () be called recursively?
What is sizeof c?
What is openmp in c?
What are different types of pointers?
How can you find the exact size of a data type in c?
What is the code for 3 questions and answer check in VisualBasic.Net?
How to establish connection with oracle database software from c language?
Is stack a keyword in c?
What is exit() function?
What is boolean in c?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
How can I change the size of the dynamically allocated array?
Explain what are reserved words?