Follow the below steps to erase the current program:
Few more examples – The following are also strings:
"0123456789"
"This is a string"
"abc123"
"1 + 1 = 2"
"[email protected]#$%^&*()"
When a dollar sign ($) is added to the end of a variable, then it is a string.
Example –
X$ = "Hello World!"
PRINT X$
Output:
Hello World!
PRINT 512 (or?512)
Now press F5 to run the program.
The program outputs: 512
2 + 2 (returns 4)
10 - 4 (returns 6)
3 * 34 (returns 102)
Example –
PRINT "Hello",
PRINT "World"
Output:
Hello World
x = 5, IF x = 5 THEN PRINT "x equals 5"
Since X does equal 5 in this case, the program outputs:
x equals 5
Expression signs
You can also enter the following statements, instead of the equals sign:
x < 5 (x is less than 5)
x > 5 (x is greater than 5)
Run the following:
x = 16
IF (x > 5) THEN PRINT "x is greater than 5"
Output:
x is greater than 5
Example –
GOTO
Run the following example program:
PRINT "1"
GOTO TheLabel
PRINT "2"
TheLabel:
PRINT "3"
Output (notice how PRINT "2" is skipped):
1
3
FOR x = 1 TO 5
PRINT x
IF (x = 2) THEN EXIT FOR
NEXT x
Output:
1
2
Programming in QBASIC
First program
Deleting the program
Strings
Commands
Expressions
Variables
The IF and THEN commands
Labels and the GOTO and GOSUB commands
Loops
Stopping loops
Q.1 |
Who was the first Scientist to develop QBASIC? |
a) | Tom Kurtz |
b) | Albert Einstein |
c) | Thomas |
d) | Bill Gates |
Q.2 |
A quantity that does not change its value during the execution of the program is called as _______? |
a) | Expressions |
b) | String |
c) | Variable |
d) | Constant |
Q.3 |
Which of the following are not allowed in a numeric constant? |
a) |
Constants |
b) | Strings |
c) | Command |
d) | Comment |
Q.4 |
It consists of sequence of characters which must be enclosed by quotation mark. It is known as _______? |
a) | Numeric Variable |
b) | Numeric Constant |
c) | String Variable |
d) | String Constant |
Q.5 |
A data type that cannot be used for mathematical operations is? |
a) | String |
b) | Long |
c) | Varchar |
d) | Integer |
Q.6 |
A command or an instruction in Qbasic is called as? |
a) | Variable |
b) | Comment |
c) | Program |
d) | Statement |
Q.7 |
Variables without a dollar sign can? |
a) | hold strings |
b) | hold numbers |
c) | hold constants |
d) | hold variables |
Q.8 |
The arithmetic operator which is used for integer division is _______? |
a) | ≥ |
b) | ≤ |
c) | / |
d) | = |
Q.9 |
Which of the following is not a reserved word or contain a space? |
a) | Numbers |
b) | Strings |
c) | Constants |
d) | Variable |
Q.10 |
These are formed from the character of the Qbasic character set. They are known as? |
a) | Reserved Word |
b) | Variable |
c) | Constants |
d) | Numbers |
Your Score: 0/10