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 / mohemmed bilal

main difference between both statement is that we can only
use switch for one variable eg
switch(x)
{
case 1://do this;
case 2://do this;
case 3://do this;
}
while in if else we can use multiple condition like
if(x==0&&y==0)
{
printf("");
}
else if(x==1&&y==0)
{
printf("");
}

Is This Answer Correct ?    0 Yes 0 No

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

Answer / manikandan

if else
is nothing but private variables.
structure is nothing but continuous allocation and public
variables and dissimilar data type.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / nabila

if else use only the statements that are in two condition

switch atatements use different cases

Is This Answer Correct ?    0 Yes 0 No

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

Answer / bakhtiar khan wazir

 
IF Statement: Checks the value of data is less than or greater than. (in ranges).
example: can tell wether an input age is more than 18 and less than 60.




Switch Case: Checks the value of data that is prespecified. only equal to. 




example: Can only generate output if the value matches. When the age is 18 or when the age is 60 . No comarison of data based on greater than or smaller than. Compares data based on equality.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / srinivasa reddy

Internally IF-ELSE implements Linear search, where as
SWITCH implements Binary search.

Is This Answer Correct ?    35 Yes 51 No

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

Answer / subbu

Basically while coding developers prefer Switch rather than
If-Else.
But inturn switch gets transferred to IF-ELSe format during
compilation.

Is This Answer Correct ?    31 Yes 87 No

Post New Answer

More C Interview Questions

main() { intx=2,y=6,z=6; x=y=z; printf(%d",x) }

5 Answers   Amazon, HCL, Thought Works,


What is class and object in c?

0 Answers  


Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant

0 Answers  


What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }

4 Answers   ADITI,


write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?

1 Answers  






How can I manipulate individual bits?

0 Answers  


simple c program for 12345 convert 54321 with out using string

7 Answers   TCS,


write a progam to display the factors of a given number and disply how many prime numbers are there?

2 Answers  


Is malloc memset faster than calloc?

0 Answers  


write a program in c language for the multiplication of two matrices using pointers?

8 Answers   Ignou,


What is the return type of sizeof?

0 Answers  


what is an inline fuction??

2 Answers  


Categories