what is the different between if-else and switch statment
(other than syntax)

Answers were Sorted based on User's Feedback



what is the different between if-else and switch statment (other than syntax)..

Answer / ailyn

Difference between switch - case and if - else is
we can't compare variables.

in the if - else, first the condition is verified,then it
comes to else whereas in the switch - case first it checks
the cases and then it switches to that particular case.

Is This Answer Correct ?    6 Yes 1 No

what is the different between if-else and switch statment (other than syntax)..

Answer / mathiyazhagan

Though both are Braching statements,The selection of
statement is depending on developers.for simple
comparisions,there is no need to SWITCH statement.switch
statement will not use to compare floating,String and
logical expressions.
we can also use switch statement to somple
comparisons ,though it not fair as following segments :
switch(a>b)
{
case 0 :
max=a;
break;
case 1 :
max=b;
break;
}
I want to conclude that if...else structure is more
flexible and reliable than switch statement.

Is This Answer Correct ?    29 Yes 25 No

what is the different between if-else and switch statment (other than syntax)..

Answer / lingaraj patra

Th switch structure is a multiple-selection structure that
allows the handling of even more complicated decision
statements other than a two-way if-else structure

Is This Answer Correct ?    5 Yes 3 No

what is the different between if-else and switch statment (other than syntax)..

Answer / nilesh dinakr

In IF STATEMENT, we can build the logical conditin i.e.
usinf realtional operator but in SWITCH, we can use the
expression which yield int or char value but not float.
char value will be auoto typecast to int. shortly , switch
works only one int

Is This Answer Correct ?    4 Yes 2 No

what is the different between if-else and switch statment (other than syntax)..

Answer / sumeet

IF ELSE- First the condition is verified, then it comes to the else part.
SWITCH CASE- First it checks the cases and then it switches to that particular case.
IF ELSE- It implements like binary search.
SWITCH CASE-
It implements binary search.

Is This Answer Correct ?    3 Yes 1 No

what is the different between if-else and switch statment (other than syntax)..

Answer / chandra

in switch case we can tell the compiler that you can go
based on user choice
where as in if-else we can test the initial cond then we can
deside

Is This Answer Correct ?    3 Yes 2 No

what is the different between if-else and switch statment (other than syntax)..

Answer / sivanandareddy y

Switch Case is used when you want to check whether a
certain variable is equal to a set of particular values and
theres a different task to do for each value.If-then-else
is can be used to check for...

Is This Answer Correct ?    1 Yes 0 No

what is the different between if-else and switch statment (other than syntax)..

Answer / ahmed

in if else if one condition is satisfied then first
statement is execute else the 2nd statement.
While in switch their is multiple choice for selection

Is This Answer Correct ?    7 Yes 7 No

what is the different between if-else and switch statment (other than syntax)..

Answer / girish patidar

switch can't check all cases but goto directly
on the perticular case but if checkes all case and verify
condition then execute.

Is This Answer Correct ?    0 Yes 0 No

what is the different between if-else and switch statment (other than syntax)..

Answer / abhay kumar

if else checks for all he conditions where as switch
directly jump to specified case.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Is it cc or c in a letter?

0 Answers  


what is constant pointer?

3 Answers  


What is a function simple definition?

0 Answers  


how to find the sizof of any datatype using bit manipulations

3 Answers  


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

0 Answers  


Write a programm such that if user enter 11.25 it roundup to 11 but if user enter 11.51 upto 11.99 it will round up to 12 i.e.;convert the floting point value into integer format as explain above..

2 Answers  


Can variables be declared anywhere in c?

0 Answers  


What are the 5 types of organizational structures?

0 Answers  


How can I access an I o board directly?

0 Answers  


1,4,8,13,21,30,36,45,54,63,73,?,?.

10 Answers   AMB, Franklin Templeton,


How do you write a program which produces its own source code as its output?

4 Answers  


Write a program for finding factorial of a number.

0 Answers   Tech Mahindra,


Categories