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

what is meant by c

9 Answers   INiTS,


What is a null pointer in c?

0 Answers  


What are keywords in c with examples?

0 Answers  


How can I ensure that integer arithmetic doesnt overflow?

0 Answers  


Write a program which has the following seven functions. The functions should be: • main() this calls the other 6 functions • fget_long() a function which returns a long data type from a file • fget_short() a function which returns a short integer variable from a file • fget_float() a function which returns a floating point variable from a file • fprt_long() a function which prints its single, long argument into a file • fprt_short() a function which prints its single, short argument into a file • fprt_float() a function which prints its single, floating point argument into a file. You should use fscanf() to get the values of the variables from the input (the file) and fprintf() to print the values to the other file. Pay attention to using the correct format for each of the data types.

0 Answers  






write a program to print largest number of each row of a 2D array

0 Answers  


how to print 212 as Twohundreds twelve plz provide me ans soon

1 Answers  


write a C code to reverse a string using a recursive function, without swapping or using an extra memory.

9 Answers   Motorola, TCS, Wipro,


hello everybody can we change a the adress of a variabl i mean can i put for exemple for a int *p: &p=6 ?????????

1 Answers  


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

0 Answers  


Explain the red-black trees?

0 Answers  


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 5 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

1 Answers  


Categories