Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Explain the difference between #include "..." And #include <...> In c?

1093


Not all reserved words are written in lowercase. TRUE or FALSE?

1279


Can two or more operators such as and be combined in a single line of program code?

1422


If null and 0 are equivalent as null pointer constants, which should I use?

1312


Is register a keyword in c?

1088


What is an identifier?

1088


Explain the advantages and disadvantages of macros.

1143


Should a function contain a return statement if it does not return a value?

1138


a c code by using memory allocation for add ,multiply of sprase matrixes

2864


How is actual parameter different from the formal parameter?

1066


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1064


What is the purpose of sprintf() function?

1186


How do I use void main?

1148


What are terms in math?

1099


What is a constant and types of constants in c?

1175