Qbasic 2
Qbasic 2
Computer Science
1
Week 2
QBasic Programming
Computer Concepts
Input & Output Devices
Binary Numbers
Computer Ports
Inside your computer
Overview of QBasic
QBasic
Introduction
A simple
language
programming
How
You
Will
Program
QBasic Lite
Main
Window
Run
Help
1 | Page
2 | Page
QBasic Lite
Program Output Window
Numeric
Integer, floating point
Strings
Used
for text
Save Output
String
order
Examples of
Numbers
5
1.5
100
3.14
1850
QBasic
Statements
A program consists
of
a
series
of statements
Statements can be
in
upper
case or lower case
in QBasic
Statements are
executed in
"Hornet"
"1850"
CSc 1, Sacramento State
Exam
ples
of
String
s
"Sac
State
"Comp
uter
Scienc
e 1"
QBasic Statements
Each tells
QBasic to:
Input data, or
Output (display)
data, or Process
data, or
Store / Retrieve Data
Function
s of a
Comput
er
Print Statement
Used to output
data
to
the screen
Can be used
to
output
numbers and
text
Not to the printer
Output Data
CSc 1, Sacramento State
CSc 1,
Sacrame
nto
State
Print Statement
having one
Syntax
statement
Example 1: Program
PRINT
PRINT Stuf
PRINT "Go
Hornets!"
Numbers and Strings
String
CSc 1, Sacramento State
Its Output
Print Example 2
Go Hornets!
PRINT 1947
Num
ber
CSc 1, Sacramento State
Print
Example
2 Output
Print
Statemen
t:
The
Semicolo
n
1947
CSc 1,
Sacramento
State
CSc 1,
Sacra
mento
State
Semicolon Example
Semicolon
Example
Output
SacState
No space?
... rocks!
Semicolon Example
CSc 1,
Sacra
mento
State
There
is
no
The Comma
space
format
The
Print
Statement
will
display
information
in
different columns
This is quite useful for
creating
nice formatted output!
CSc 1,
Sacra
mento
State
Comma Example 1
Comma Example 1
Output
Team 1
Sac State
Team 2
Idaho
CSc 1,
Sacramento
State
Comma Example 2
CSc 1,
Sacra
mento
State
Comma
Example
Output
Cherry
Lemon
Chocolate
Red
Yellow
Brown
CSc 1,
Sacramento
State
CSc 1,
Sacra
mento
State
Comma Example 3
PRINT "University:",
"Sac State"
Comma
Example
Output
CSc
1,
Sacr
ame
nto
State
Print
Statement
Summary
Cls Statement
Used to
clear the
screen
Any
information
on
the output
screen will
disappear
Commas:
columns
excellent for formatted
output
put items into
Semicolons:
put items next to each other
excellent for combining
information
Cls Example
this."
CLS
CLS
PRINT Really?!"
Pretty simple!
CSc 1, Sacramento State
Really?!
CSc 1,
Sacra
ment
o
State
Cls Example
Poof!
The
output before
CLS
was
cleared
(remarks) to
your program
They don't do anything
Makes programs easier to
read
They start with either REM or
a
single quote
Rem Statement
CSc 1,
Sacrame
nto
State
Rem Example
Rem Example 2
Your First Program Hello
World!
' I am a remark
'
Computer
Science 1 ' Sac
State
' Lab #1
CSc
1,
Sacr
ame
nto
State
CSc 1,
Sacra
mento
State
QBasi
c Lab
Func
tions
of a
Com
pute
r
Input
&
Output
LCD
Liquid Crystal Display
Clearer, low radiation emission, portable,
and
compact
LED
Devices
Function
s of a
Compute
r
Analog
Digital
CSc 1,
Sacramento
State
Monitors
CRT
This
Trackball
ocess
nput Data
Pr
Data
tore Data
Data
similar to a mouse
CSc 1,
Sacra
mento
State
S
Output
CSc
1,
Sacr
ame
nto
State
Nozzle-like print
head
Sprays ink onto paper
to form
characters and graphics
Keyboard
Mouse
Touchpad
used primarily
laptops
replacement
for the mouse
on
Laser Printers
Use a laser to
paint
dots
laser
Used rarely
nowadays
for low-quality
output
to print multipart carbon forms
CSc 1,
Sacrame
nto
State
Write Head
Binary Encoding
CSc 1, Sacramento State
How do
computers
store
numbers
The
Numeric
System we use
positional
grouping system
each position represents a power of 10
Binary numbers
What is a Number?
but
CSc 1,
Sacrame
nto
State
Base 10 Numbers
(decimal numbers)
Binary Numbers
Example
104
103
21
10000 1000
2
1
0
0
102
20
101
100
100
1
7
1
10
27
24
23
22
128 64 32 16
26
25
64 + 32 + 8 + 1 = 105
Binary Numbers
Example 2
The number 1100 1011 is ...
27
26
25
24
23
22
21
20
12
81
64 32 16
1
0
0
8
1
4
0
2
1
1
1
128 + 64 + 8 + 2 + 1 = 203
CSc 1, Sacramento State
data
Binary Encoding
again
How do
computers
store
other
types of
10
Data representation
how letters,
A digital device
An analog device
How Data is
Represented
CSc 1,
Sacrame
nto
State
Digital Representation
Computers
are digital
A bit is one
binary digit
Either 1 or 0
The most basic symbol used in
computers Shorthand for a bit is b
A byte is 8
bits
Just as a standard
light ...
e.g. 0010
0100
The basic group of symbols used in
computers Shorthand for a byte is B
CSc 1,
Sacrame
nto State
Quantities of
Bits & Bytes
Bits
Bytes
Are used to
represent
everything
Examples:
Numbers
Letters,
punctuation, etc...
Pictures
Sounds
CSc 1,
Sacrame
nto State
Co
m
pu
ter
Po
rts
Connecting Devices to
Your Computer
CSc 1, Sacramento State
11
Expansion Ports
s
e
n
d
s
Used to
connect a
a
n
a
l
o
g
peripheral
device
Expansion port
any
connector that
passes data
in and out of a
computer
or
peripheral
device
d
a
t
a
DVI
D
ig
it
al
V
is
u
al
In
te
rf
a
c
e
Original Ports
Serial
was
the
first
microcomputer port
been around since the
70's
slow 56 Kbps
Parallel
faster 12 Mbps
(12,000 Kbps) was
primarily
used
for
printers not used
anymore
s
e
n
d
s
di
gi
ta
l
d
at
a
Monitor Ports
VGA
Video
Graphics Array
Keyboards
Mouse sometimes
Limitations
keyboard & mouse ports are
dedicated do not remove cables
while running
CSc 1,
Sacrame
nto State
12
Main developers:
Apple
Computer
hundreds of companies
Hewlett-Packard
in charge of standards
Intel
NEC
Microsoft
Major Features:
Released in 1996
Speed: 12 Mbps not that
fast
CSc 1, Sacramento State
Designed to be hi-speed
Developers:
Released in 2001
Speed: 480 Mbps
HewlettPackard
Intel
Luc
ent
Mic
ros
oft
CSc 1,
Sacrame
nto
State
NE
C
Philips
CSc 1, Sacramento State
Port
Serial
/ 2 or USB
Parallel
Need It?
Now
No
No
Notes
Computer Ports
Through Time
Port
Obsolete
Keyboard
Obsolete
Mouse
Then
PS / 2
PS / 2 or Serial
PS
PS
/ 2 or USB
PS/2
VGA
DVI
FireWire
USB
Probably
Used for keyboards
VGA or DVI
Yes
Widely used for monitors
USB
Maybe
Great for digital monitors
USB
Maybe
Useful for old hardware
USB
Yes!
The more - the better
USB
Monitor
VGA
Printer
Parallel
Scanner
Parallel
Joystick
Game
Flash Drive
13
Didn't exist!
14