blogger Indonesia

Follow judhyns blog

THE if STATEMENT

Introduction

The if statement is the first selection structure. if is used when a question requires a yes or no answer. If you want to choose an answer from several possibilities then use the switch statement.

Program/Example

The general format for an if statement is:

if ( condition ) simple or compound statement. 

Following are the properties of an if statement:

  1. If the condition is true then the simple or compound statements are executed.

  2. If the condition is false it does not do anything.

  3. The condition is given in parentheses and must be evaluated as true (nonzero value) or false (zero value).

  4. If a compound statement is provided, it must be enclosed in opening and closing braces.

Following are the test conditions:

    (7)// a non-zero value returns True. (0)// zero value returns False. (i==0)    // True if i=0 otherwise False. (i = 0)    // False because value of the expression is zero. 

No comments:

feed

PR Check

activesearchresults

judhyn's blog

 

http://www.judhyn.blogspot.com | |