what is the different between if-else and switch statment
(other than syntax)
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / srinivasa reddy
Internally IF-ELSE implements Linear search, where as
SWITCH implements Binary search.
| Is This Answer Correct ? | 35 Yes | 51 No |
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 |
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures
What is the use of printf() and scanf() functions?
12345 1234 123 12 1
Explain what is operator promotion?
how to make a scientific calculater ?
how to compare two strings without using strcmp() function??
what is develop in c language
What is the description for syntax errors?
How is = symbol different from == symbol in c programming?
yogesh patil in dell
why ordinary variable store the later value not the initial
say the following declaration is correct nr not. int b=a,n=0;