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

What does int main () mean?

1032


Explain union.

1176


what will be maximum number of comparisons when number of elements are given?

1909


What is a dynamic array in c?

1162


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

2749


What are global variables and explain how do you declare them?

1108


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

1126


What is the purpose of main() function?

1256


what do you mean by enumeration constant?

1015


What are the different types of linkage exist in c?

1035


Why we not create function inside function.

2199


What is a ternary operator in c?

1127


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1701


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1814


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

1113