Computer Science, asked by MohamedDanish6529, 11 months ago

What is the difference between the if and switch statement???

Answers

Answered by charlie1505
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