Post on 18-Jul-2015
COMPUTER
PROGRAMMIN
GPREPARED BY:
PAGADUAN, JOANNE A.
VIJUNGCO, ARISA MAE D.
GRADE 9 SSC LAVOISIER
MR. ANGEL CORONA
COMPUTER PROGRAMMING ADVISER
RETRIEVING
KEYBOARD
INPUT FROM
THE USER
INPUT
commandOne way to receive input from the keyboard is with the INPUT command.
Allows the user to enter a string or a number, then stored in a variable.
REMEMBER:
If the program is executed, the INPUT command
displays a question mark, and followed by a
blinking cursor.
TIP:
If you place a string and a semi- colon between
INPUT and the variable, the program will print the
string.
INPUT “Please enter some text:”;
The IF and THEN
command It is used to compare an expression and the
perform some task based on that expression.
x=3
IF x=3 THEN PRINT “x equals to 3”
Since X does equal 3 in this case, the program outputs:
X equals to 3
EXPRESSION
Signs< (less than)
> (greater than)
<> (does not equal)
<= (less than or equal)
>= (more than or equal)
NOTE:
Some signs that can be used instead of = (equal)
sign.
ELS
EIt helps the program to perform different action if the
statement is false.
x=8
If x= 7 THEN PRINT “YES” ELSE PRINT “NO”
Since X doesn’t equal to 8, the output is:
NO
END
IFIt helps you to have multiple
commands after the IF… THEN statement.
They must start on the line after the IF statement.
END IF should appear right after the list of commands.
INPUT “Please enter a number”, x
IF x< 6 THEN
PRINT “YES”
ELSE
PRINT “NO”
END IF
Proceed to next slides for
exercises
Test your
skills!
OBJECTI
VES: TO ENHANCE SKILLS IN COMPUTER PROGRAMMING USING THE
WIDELY KNOWN AND ACCEPTED PROGRAMMING LANGUAGE,
QBASIC.
TO EASILY GRASP THE BASICS OF COMPUTER PROGRAMMING
THROUGH THE USE OF QBASIC.
PROCED
URE: ANSWER THE FOLLOWING EXERCISES THROUGH THE USE OF
QBASIC.
USE QBASIC FOR COMPUTER PROGRAMMING FOR THE EXERCISES
READIED/MADE BY THE PRESENTERS.
EXERCISE 1:
IF- THENPROGRAM
x=143
IF x = 143 THEN PRINT “I LOVE YOU”
PROGRAM
x=333
IF x = 123 THEN PRINT “BLACK”
EXERCISE 2: IF-
THEN ELSEPROGRAM
x = 100
IF x=90 THEN PRINT “LOL” ELSE PRINT “ULOL”
IF x=143 THEN PRINT “HAH” ELSE PRINT “HUH”
IF x<10 THEN PRINT “OKAY” ELSE PRINT “LANG”
IF x>100 THEN PRINT “WHATEVER” ELSE PRINT “TSK”
IF x<> 99 THEN PRINT “MAGANDA” ELSE PRINT “PANGIT”
EXERCISE 3: IF- THEN-
ELSE- END IF
This is about choosing to do either one thing or another (simple
selection). This is a test in the use of the IF instruction. The If instructions
spans many lines and includes four (4) keywords, IF, THEN, ELSE, END IF.
Create a program that will ask you a number. It will then print
out the word KIND. If the number is greater than 50 or the word RUDE if it
is not.
NOTE* Two (2) programs for both outputs.
Instructions:
EXERCIS
E 1PROGRAM
:
OUTPUT:
The output should be
[ I LOVE YOU ]
since the given data satisfied the condition
PROGRA
M: OUTPUT:
The output should be just blank since the given data
did not satisfy the condition.
EXERCISE 2
PROGRAM:
OUTP
UT:
EXERCISE 3PROGRAM:
OUTP
UT:
PRESENTED BY:
PAGADUAN,
JOANNE A.
VIJUNGCO, ARISA
MAE D.
PRESENTED TO:
MR. ANGEL
CORONA
GRADE 9 SSC
VIJUNGCO, ARISA MAE D.PAGADUAN, JOANNE A.
END