Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 109 - 2505_CoreGPT(Podar)_Flipbook_C6
P. 109

    IF-THEN STATEMENT

                     The  IF-THEN statement is  the simplest  conditional               Start
                     statement. Here,  certain statement or block of

                     statements within the if block is  executed  only if                                    Execute
                                                                                         Is
                     specified condition evaluates to true. If the condition                       Yes     statement(s)
                                                                                     condition
                     evaluates to false, then the control  of execution is
                                                                                        true
                     passed to the last statement, outside the if block.
                                                                                     No
                     The syntax of the IF-THEN statement is given below:

                     Syntax:                                                       Statement after
                                                                                       END IF
                     IF <condition> THEN

                       Statements to be executed
                     END IF                                                             Stop

                     Program 2: To demonstrate IF-THEN statement.

                           IF-THEN-ELSE STATEMENT
                                                                                              Start
                     The  IF-THEN-ELSE statement checks for
                     a condition.  If the condition evaluates to
                     true,  the indented statements following                                  Is
                                                                                  Yes                    No
                     the  if statements are  executed,  otherwise                          condition

                     the indented statements following the else                               true
                     statement  are  executed.  The  syntax  of  the        Execute                         Execute
                     IF-THEN-ELSE statement is given below:              commands in                     commands in
                                                                          the IF block                  the ELSE block
                     Syntax:

                     IF <condition> THEN
                          Statements to be executed                                            Stop

                                                                                    More on BASIC-256 Statements        107

| 104 105 106 107 108 109 110 111 112 113 114 |