What is the difference between the if and switch statement???
Answers
Answered by
2
Answer:
if is condtional statement, return 1 when condition is true.
otherwise returns 0 if condition is false.
Use if when we have to return true or false only
switch statement use when we have more than 2 conditions.
Explanation:
Syntax for if
if(condition)
{
return true;
}
else
{
return false;
}
syntax for switch case-
switch (expression)
{
case constant1:
// statements
break;
case constant2:
// statements
break;
.
.
.
default:
// default statements
}
Similar questions
Chemistry,
5 months ago
Computer Science,
5 months ago
English,
11 months ago
English,
11 months ago