In the following control structure which is faster?
1.Switch
2.If-else
and which consumes more memory?
Answers were Sorted based on User's Feedback
Answer / battini.laxman
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 ? | 8 Yes | 1 No |
Answer / abhradeep chatterjee
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 |
Answer / vignesh1988i
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 ? | 1 Yes | 1 No |
Answer / deepak upadhyay
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 | 1 No |
I want tcs placement papers of 2004-2009 , its urgent
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
how to write a cprogram yo get output in the form * *** ***** ******* ********* ******* ***** *** *
write a program to print infinte number
a program that can input number of records and can view it again the record
Can you think of a way when a program crashed before reaching main? If yes how?
Write a program to swap two numbers without using a temporary variable?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
What are the advantages of external class?
how to find a 5th bit is set in c program
How many identifiers are there in c?
2. What does static variable mean?