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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by int main ()?

719


What is void c?

569


Why is c called "mother" language?

859


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

784


What are keywords in c with examples?

606






Are global variables static in c?

677


Do you know the purpose of 'register' keyword?

643


What is wrong with this declaration?

614


What does & mean in scanf?

605


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

665


What is the scope of static variable in c?

537


What is the scope of an external variable in c?

570


What is the best style for code layout in c?

633


An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array

688


why do some people write if(0 == x) instead of if(x == 0)?

655