COMPUTER PROGRAMMING

20
COMPUTER PROGRAMMI G PREPARED BY: PAGADUAN, JOANNE A. VIJUNGCO, ARISA MAE D. GRADE 9 SSC LAVOISIER MR. ANGEL CORONA COMPUTER PROGRAMMING ADVISER

Transcript of COMPUTER PROGRAMMING

Page 1: COMPUTER PROGRAMMING

COMPUTER

PROGRAMMIN

GPREPARED BY:

PAGADUAN, JOANNE A.

VIJUNGCO, ARISA MAE D.

GRADE 9 SSC LAVOISIER

MR. ANGEL CORONA

COMPUTER PROGRAMMING ADVISER

Page 2: COMPUTER PROGRAMMING

RETRIEVING

KEYBOARD

INPUT FROM

THE USER

Page 3: COMPUTER PROGRAMMING

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.

Page 4: COMPUTER PROGRAMMING

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:”;

Page 5: COMPUTER PROGRAMMING

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

Page 6: COMPUTER PROGRAMMING

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.

Page 7: COMPUTER PROGRAMMING

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

Page 8: COMPUTER PROGRAMMING

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.

Page 9: COMPUTER PROGRAMMING

INPUT “Please enter a number”, x

IF x< 6 THEN

PRINT “YES”

ELSE

PRINT “NO”

END IF

Page 10: COMPUTER PROGRAMMING

Proceed to next slides for

exercises

Test your

skills!

Page 11: COMPUTER PROGRAMMING

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.

Page 12: COMPUTER PROGRAMMING

EXERCISE 1:

IF- THENPROGRAM

x=143

IF x = 143 THEN PRINT “I LOVE YOU”

PROGRAM

x=333

IF x = 123 THEN PRINT “BLACK”

Page 13: COMPUTER PROGRAMMING

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”

Page 14: COMPUTER PROGRAMMING

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:

Page 15: COMPUTER PROGRAMMING

EXERCIS

E 1PROGRAM

:

OUTPUT:

The output should be

[ I LOVE YOU ]

since the given data satisfied the condition

Page 16: COMPUTER PROGRAMMING

PROGRA

M: OUTPUT:

The output should be just blank since the given data

did not satisfy the condition.

Page 17: COMPUTER PROGRAMMING

EXERCISE 2

PROGRAM:

OUTP

UT:

Page 18: COMPUTER PROGRAMMING

EXERCISE 3PROGRAM:

OUTP

UT:

Page 19: COMPUTER PROGRAMMING

PRESENTED BY:

PAGADUAN,

JOANNE A.

VIJUNGCO, ARISA

MAE D.

PRESENTED TO:

MR. ANGEL

CORONA

GRADE 9 SSC

VIJUNGCO, ARISA MAE D.PAGADUAN, JOANNE A.

Page 20: COMPUTER PROGRAMMING

END