Conditional statements  switch

Chapter 1: Overview

if/else

The if/else statement has three formats:

Table 1-8: If/else statements

Format

Meaning

if (condition)

{

do this;

}

If the condition evaluates to true, then the “do this” statement is executed.

if (condition)

{

do this;

}

else

{

do that;

}

If the condition evaluates to true, then the “do this” statement is executed.

If the condition evaluates to false, then the “do that” statement is executed.

if (condition1)

{

do this;

}

else if (condition2)

{

do that;

}

else

{

get this done;

}

If condition 1 evaluates to true, then the “do this” statement is executed.

If condition1 evaluates to false and condition2 evaluates to true, then the “do that” statement is executed.

If neither condition is true, then the “get this done” statement is executed.

Note This format may contain more than one “else if ()” statement.





Copyright © 2005. Sybase Inc. All rights reserved. switch

View this book as PDF