ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
In the following control structure which is faster?
1.Switch
2.If-else
and which consumes more memory?
 Question Submitted By :: Praveen
I also faced this Question!!     Rank Answer Posted By  
 
  Re: In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?
Answer
# 1
switch is faster because when in nested if condition has to 
check for each time. where as in switch it diectly check 
only labels.
 
Is This Answer Correct ?    5 Yes 0 No
Battini.laxman
 
  Re: In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?
Answer
# 2
as for as me is concerned switch is faster....

in if-else first it will check the if condition , if it is 
true it's no problem.. but if it falls false, it will go 
to  the else part ... 

but in switch case , the argument given inside switch 
statement will see and automatically to the necessary case 
of it... so by comaring the time constraint ,switch saves 
the time for checking each else statement for every if....


thank u
 
Is This Answer Correct ?    0 Yes 0 No
Vignesh1988i
 
 
 
  Re: In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?
Answer
# 3
switch statement is more faster and consumes less memory 
than if-else statement the reason being that the switch 
statement is applied  when we have a single variable to 
check but in case of if-else different variable may be 
checked at the same time.
 
Is This Answer Correct ?    1 Yes 0 No
Deepak Upadhyay
 
  Re: In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?
Answer
# 4
According to me, switch is faster. cause in nested if- 
else, the checking occurs in each step. So, more the 
compiler checks, the more it takes time. So switch case is 
faster.
 
Is This Answer Correct ?    1 Yes 0 No
Abhradeep Chatterjee
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is a symbolic constant?  1
N O S I E R + A S T R A L ---------------- 7 2 5 6 1 3 Honeywell2
I have an array of 100 elements, each of which is a random integer. I want to know which of the elements: a) are multiples of 2 b) are multiples of 2 AND 5 c) have a remainder of 3 when divided by 7  1
wite a programme in c to linear search a data using flag and without using flags? TCS3
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.  2
Write a C program to print 1 2 3 ... 100 without using loops?  5
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output? Ramco5
n=7623 { temp=n/10; result=temp*10+ result; n=n/10 } Wipro4
Dear Sir, we are required the bubble sorting programs Regs Prem  1
Name the language in which the compiler of "c" in written? Bajaj1
what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?  2
How to avoid structure padding in C? Tech-Mahindra4
a C prog to swap 2 no.s without using variables just an array? TCS4
Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values stored so that value a goes to b,b,to c and c to a  3
The C language terminator is a.semicolon b.colon c.period d.exclamation mark TCS3
Difference between fopen() and open()? Aricent3
how we can make 3d venturing graphics on outer interface Microsoft1
what are the languages used in c#? Infosys1
#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf("hello \n"); return 0; } int fun() { printf("hi"); } answer is hello.how??wat is tat while(i) mean? Intel4
implement general tree using link list Wipro1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com