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 is the process of writing the null pointer?
What is the scope of static variable in c?
How does selection sort work in c?
Can we change the value of static variable in c?
How can I call fortran?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Explain what is the heap?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
string reverse using recursion
What does the file stdio.h contain?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Difference between strcpy() and memcpy() function?
Why is c so popular?
How to set file pointer to beginning c?
What is the use of clrscr?