A switch statement , Computer Engineering

Which is more efficient, a switch statement or an if else chain?

Ans) The differences, if any, are likely to be small. The switch statement was designed to be efficiently implementable, though the compiler may want to use the equal of an if/else chain (as opposed to a compact jump table) if the case labels are sparsely distributed.

 

 

Posted Date: 4/8/2013 3:12:34 AM | Location : United States







Related Discussions:- A switch statement , Assignment Help, Ask Question on A switch statement , Get Answer, Expert's Help, A switch statement Discussions

Write discussion on A switch statement
Your posts are moderated
Related Questions
State and prove Demorgan’s First theorems: Ans. Statement of First Theorem of De Morgan: = A‾. B‾   Proof: The two sides of the equation i.e. = is represented with logic

Data Transfer Two most fundamental data transfer instructions in 8086 microprocessor are XCHG and MOV. Let's give illustrations of the use of these instructions. Program 1:

Q. Example of asymptotic notations? The function f (n) belongs to the set  (g(n)) if there exists positive constants c such that for satisfactorily large values of n we have 0

The fields specified by select-options and parameters statement cannot be grouped together in the selection screen. No, the fields specified by select-options and parameters s

Q. Conversion of BCD number to binary using a procedure? Conversion of BCD number to binary using a procedure. Algorithm for conversion procedure: Take a packed BCD digit

Define MFC. To accommodate the variability in response time, the processor waits unless it receives an indication that the requested read operation has been done. The control s

What are the events done by the Kernel after a process is being swapped out from the main memory? When Kernel changes the process out of the primary memory, it performs the fol

Role of Internet, Intranet and extranet in e-business The following information activities are carried out in many business: 1.  Selling of raw materials 2.  Advertising o

Latch is a D- type flip-flop used as a temporary storage device controlled by a timing signal, which can kept 0 or 1. The primary function of a Latch is data storage. It is used in

Convenience of Environments -artificial intelligence: In some cases, some aspects of an environment which should be taken into account in decisions about actions may be unavai