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


Please Help Members By Posting Answers For Below Questions

What is ## preprocessor operator in c?

607


What is the difference between volatile and const volatile?

556


What is a function in c?

567


explain how do you use macro?

661


What is masking?

629






Why is this loop always executing once?

611


What is operator precedence?

637


1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if

3973


can any one provide me the notes of data structure for ignou cs-62 paper

1694


how many key words availabel in c a) 28 b) 31 c) 32

627


What is the function of multilevel pointer in c?

665


What are void pointers in c?

570


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

736


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2328


Can 'this' pointer by used in the constructor?

608