Microsoft PowerPoint - QBasicFunctions
Microsoft PowerPoint - QBasicFunctions
Computer Science 1
Week 5 • QBasic Programming
Š Built
Built--in functions
• Computer Concepts
Š Networks
Š The Internet
• Questions on Project #1?
QBasic Built
Built--in
Functions
QBasic Built-
Built-in QBasic Built-
Built-in
Functions Functions
• Built
Built--in Functions • Often, a function takes an input
Š part of the QBasic programming language Š it returns an output according to the function
Š returns a value – just like in algebra! Š data given to a function is an argument
• Used in expressions • Strings vs. Numeric functions
Š allows complex mathematics Š functions that end in $ return a string
Š allows better control of strings otherwise,, it returns a number
Š otherwise
1
Function Call Syntax Some Built
Built--in
Number Functions
Function Returns
Name of the function SIN mathematical sine
COS mathematical cosine
Name ( Arguments ) RND random number between 0 and 0.99...
INT integer (no decimal values)
Zero or more
VAL value of a string (convert)
DIM Value 45
LET Value = 45.123 Decimal value
removed
PRINT INT(Value)
2
COS() Example COS() Example
Output
Some Built
Built--in String Review
String Functions
Function Returns
LTRIM$ left spaces trimmed (removed) DIM User AS String
MID$ middle part of the string (substring)
LCASE$ string in lowercase LET User = "Joe Gunchy"
UCASE$ the string in uppercase
PRINT User
STR$ string for a number (convert)
3
String Review UCASE$() Example
Output
4
Multiple Function
Example Output
• Objectives
Š use variables
Š use built-
built-in functions
• Your Program
Š calculate how much fuel your ship needs
Š calculate the perimeter of a polygon Your flight plan
inscribed inside a circle
• Azeroth
• Grue
• LV
LV--426
• Maximegalon
• Turn your program & your output
• Marklar Š Lab 4 in SacCT
• Spaceball
• Yugopotamia
• Vogsphere
5
Essay
Project
Remember...
What is a Network?
6
Networking Network
Advantages Disadvantages
• Bandwidth
• Personal Area Network Small Š capacity of a communications channel
• Local Area Network • High
High--bandwidth systems
• Neighborhood Area Network Š sometimes referred to as broadband
Š excellent for transmitting multimedia
• Metropolitan Area Network
Large • Low
Low--bandwidth systems
• Wide Area Network Š sometimes referred to as narrowband
Network Links
• Wired network
Š data travels between devices over a cable
• Wireless network
Š data travels between devices through radio waves
in the air
• Communication channels
Š physical path or a frequency
Š e.g. computer cables, cell phone frequency
7
What is a Protocol?
• Format
How Computers Talk Š how data is transmitted
• London Bridge
• Application Layer
Š commuter bridge constructed in 1831
• Transport Layer Š don't confuse it with the London's Tower Bridge
8
London Bridge is London Bridge is
Falling Down ... Moving 'round
• Robert P. McCulloch
• Break the bridge into pieces
Š businessman
Š since the bridge is masonry
Š bought London Bridge Š “bricks” was the logical choice
Š decided to move it to Lake • Each was labeled carefully
Havasu City, Arizona, and Š the span it was in - 5 total
rebuilt it in 1971 Š the row of stone it was in
• How do you move a bridge? Š its position in the row
Application Layer
• The "Bridge
g Structure"
• Top
Top--most layer
• Protocol depends on the application
Š what type of data is being sent
Š what extra information is needed
9
Transport Layer Network Layer
• The Internet uses TCP (transmission control protocol) • The Internet uses IP (internet protocol)
Protocol Layer
Summary
10
What is the Internet?
11
The Internet Uses
TCP / IP
• Provides a standard
Š refers to the Network and Transport layers
Š easy to implement and extensible
Š public and free
NAP Backbone
• TCP / IP is ...
Š the standard network and transport layers
Š allows all the networks to communicate
Š used by websites & e e--mail • Domain Name Servers house the database
12
Top Level Domains Open Top Level
(TLD) Domains
13
ICANN Now Allows
Custom TLDs!
14