give the syntax of if-else and switch statements


Give the syntax of "if-else" and "switch" statements and explain.

if else

This is used to decide whether to do something at a special point, or to decide between two courses of action.

Syntax of  if else

if (conditional expression) Statement1;

else

Statement2;

The following test decides whether a student has passed an exam with a pass mark of 45 if (result >= 45)

printf("Pass\n");

else

printf("Fail\n");

It is possible to use the if part without the else.

 

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: give the syntax of if-else and switch statements
Reference No:- TGS0305394

Expected delivery within 24 Hours