what is the different between if-else and switch statment
(other than syntax)
Answer Posted / 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 |
Post New Answer View All Answers
What is else if ladder?
What are the disadvantages of a shell structure?
In a header file whether functions are declared or defined?
What is a buffer in c?
Why calloc is better than malloc?
Explain what is the difference between null and nul?
What is double pointer?
What is #include called?
What is the purpose of ftell?
how to find binary of number?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
p*=(++q)++*--p when p=q=1 while(q<=6)
How do I use strcmp?
we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above
What are the different types of control structures?