Wednesday, June 20, 2012

QBasic 64 : You’re Gonna Get It! IF THEN Statement

The IF-THEN-ELSE statement is called growing up as children (even some adults) are programmed into becoming human beings. This is a computer statement which involves true-false logic just like real life.  Even the smallest child quickly learns the logic of this programming statement.

IF it’s true you do something wrong THEN there will be consequences ELSE it’s false you did not do anything wrong there will be different consequences, END IF.  

IF you put that ice cream in your mouth THEN

you’re gonna be in big trouble young man    {if TRUE something happens}

ELSE

            you will not be in trouble     {if FALSE, something else will happen}

ENDIF


In our first program, we entered to numbers, guessed at the answer and we will use the If-Then statement to test the results with the correct answer.

INPUT:  Num1 = First numbered inputted
               Num2 = Second number inputted
               Ans = Our guess for the correct answer

PROCESS:

Corr = Num1 * Num2

IF Ans = Corr THEN

            PRINT “ You are correct”
ELSE
                        PRINT ”You’re a Moron”
END IF


Family Guy - I Want Ice Cream posted by huluDotCom.

No comments:

Post a Comment