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
What is meant by int main ()?
What is void c?
Why is c called "mother" language?
#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); }
What are keywords in c with examples?
Are global variables static in c?
Do you know the purpose of 'register' keyword?
What is wrong with this declaration?
What does & mean in scanf?
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
What is the scope of static variable in c?
What is the scope of an external variable in c?
What is the best style for code layout in c?
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
why do some people write if(0 == x) instead of if(x == 0)?