Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

TakeHomeActivity#2_Numbers & the PRINT Statement

Direction: Read the following information about Numbers and the PRINT Statement. Follow the instructions and write
your answers in your notebook.
Numbers and the PRINT Statement
When you run a program with a 1)._______________ command, everything inside the two 2)._______________
marks will be shown on the screen. To show 3)._______________, you must also put them inside the quotation marks.
Type the following codes on the left in QBasic program and write the screen output on the right.

4). What did you notice when you run the program?
__________________________________________________________________________________________________
__________________________________________________________________________________________________
Type the following codes on the left in QBasic program and write the screen output on the right.
5).
6).
7). What did you notice when you run the program?
__________________________________________________________________________________________________
__________________________________________________________________________________________________
Strings

There are certain types of data (or information) called "strings. Strings contain a sequence of characters (letters,
numbers, and 8)._______________) enclosed in quotation marks. For example, "Hello World!" is a string.
The following are also strings:
"0123456789"
"This is a string"
"abc123"
"1 + 1 = 2"
"!@#$%^&*()"
Expressions
An expression is something that the program calculates (or evaluates). Such as:
1+1
(returns 9).________)
100 - 47
(returns 10)._______)
3 * 34
(returns 11)._______)
80 / 4
(returns 12)._______)
(100 * 3) + 56 (returns 13)._______)
If you pass an expression to the PRINT command, the value returned (a number) is printed.
Clear the current program, and then run the following:
PRINT 512 + 478
Program output:
14).______________
If you enclose the expression with quotation marks, the expression becomes a string and isn't evaluated. For example:
PRINT "512 + 478"
Output:
15).______________

Operations in Math
Since we are going to perform some computations, let us recall the basic operations, operators, and operands.
The table below discusses the operators, the symbols used, some examples and their results. Fill in the blanks to
complete the data in the table.
Meaning
1.
2.
3.
4.
5.
6.
7.

Addition
Subtraction
Multiplication
Division
Integer Division
Remainder after Division
Exponentiation

Operator
(Symbol used in the computer)
+
* (asterisk)
/
\
MOD
^ (caret)

Sample
45 + 8
137 25
34 * 87
75/3
64 \ 3
8 MOD 3
3^2

Result
1).________
112
2).________
3).________
21
4).________
5).________

Instead of an x for multiplication, the computer uses the asterisk (*) symbol. This is found on top of the number
8 key in the keyboard. Just press the 6)._______________ key plus the number 8 key. The remainder after division, just
type the three letters 7)._______________. For the exponentiation, look for the caret sign found on the number
8)._______________ key in the keyboard. Same with asterisk, just press SHIFT key together with the number 6 key.
Type the CODE on the left and write the screen output on the right.
9).

10). What did you notice when you run the program?
__________________________________________________________________________________________________
__________________________________________________________________________________________________
Order of Operation
The computer also follows the 1)._______________ to Right rule and PEMDAS rule in Math when evaluating
arithmetic expressions. 2)._______________
means Parenthesis, 3)._______________, Multiplication, Division,
4)._______________ and Subtraction.

1.
2.
3.
4.
5.

The table below shows the priority of the 5)._______________. The highest priority is what comes first.
OPERATION
OPERATOR
(6)._______________ used in the computer)
Exponent
^
7)._______________ , Division
* (asterisk), /
8)._______________ Division
\
Modular (remainder after division)
MOD
Addition, 9)._______________
+,

The arithmetic 10)._______________ below will be evaluated as follows:

You might also like