1.

Give two differences between the switch statement and the If-else statement.

Answer»
Switch statementif-else statement
In this statement, multicodes can be provided in which control transfers to different parts of the code based on the value of an expression.
Syntax :
if (condition)
{
statements;
}
Else
{
statements;
}
In this statement, there are only two codes based on either a true or a false con
Syntax :
switch (expression)
{
case constant 1;
statement 1;
break;
case constant 2;
statement 2;
break;
:
:
default :
statement sequence;
}
case



Discussion

No Comment Found

Related InterviewSolutions