23.03.2017 Views

wilamowski-b-m-irwin-j-d-industrial-communication-systems-2011

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

62-4 Industrial Communication Systems<br />

62.3.2 Conditional Statements<br />

Conditional statements such as, if, if…else, if…elseif…else, switch statements are used to perform<br />

different actions based on different decisions.<br />

a. An if statement is used to execute the code only if a specified condition is true.<br />

<br />

b. An if….else statement is used to execute some code if a condition is true and another code if<br />

condition is false.<br />

<br />

c. An if…elseif…else statement is used to selectively execute some code when a condition is true.<br />

<br />

d. A switch statement is used to execute one of many blocks of code.<br />

Example:<br />

//Switch Statement<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!