If Statement

The Basics

Definition - An if Statement is a block of code that is associated with a condition. The block of code may execute ONCE or not at all depending on the evaluation of the condition.

Syntax -

If (Boolean condition)

{

do something 1 ;

do something 2;

}

Common Errors

(total >= 25 ) ;

{

}

--Don't need semicolon

--forgot if

if

{

}

--forgot Boolean condition

Comment Stream