The Basic Language - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

The Basic Language

Description:

'Michael Jackson' '726' The value of a string constant remains unchanged during the program. ... This format will confuse the computer! What should we write? G ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 25
Provided by: lanceco2
Category:

less

Transcript and Presenter's Notes

Title: The Basic Language


1
The Basic Language
  • Molloy College
  • CIS103 Visual Basic
  • Dr. Cohen

2
What Is a Program?
  • 100 REM PROGRAM TO AVERAGE THREE NUMBERS
  • 110 REM X, Y, AND Z DENOTE NUMBERS
  • 120 REM A DENOTES AVERAGE

3
What Is a Program?
  • 130 LET X43
  • 140 LET Y27
  • 150 LET Z23
  • 160 LET A(X YZ)/3
  • 170 PRINT AVERAGE IS, A
  • 180 END

4
Output
  • AVERAGE IS 31

5
Numerical Constants
  • Integer 726 or 726
  • Decimal 726.00 or 7.26
  • Floating Point 1E4 1 X 104
  • The value of a constant does not change during
    the program.

6
Numerical Variables
  • A
  • A1
  • SUM
  • Sum1
  • The value of a variable can change during the
    program.

7
String Constants
  • X
  • Michael Jackson
  • 726
  • The value of a string constant remains unchanged
    during the program.

8
Assigning Value
  • In Basic the Let statement assigns a value

9
Assigning Value
  • If A2, B-2, C3, and AABC
  • Then
  • Let SABC S
  • Let XA1 X
  • Let Y4 Y
  • Let RA R

10
Assigning Value
  • If A2, B-2, C3, and AABC
  • Then
  • Let SABC S 3
  • Let XA1 X 3
  • Let Y4 Y 4
  • Let RA R ABC

11
Assigning Value
  • Let NN1
  • If N6 Then
  • NN1 assigns a value to N of

12
Assigning Value
  • Let NN1
  • If N6 Then
  • NN1 assigns a value to N of 7
  • Such expressions are used to create loops.

13
Interaction
  • Input a variable or string
  • 10 Input D
  • 20 Let C12D
  • If the user types D as 10 then C

14
Interaction
  • Input a variable or string
  • 10 Input D
  • 20 Let C12D
  • If the user types D as 10 then C22

15
Making Decisions
  • 100 Input x
  • 110 If xgt10 then T.5x
  • 120 Else Tx
  • If x6, what is T?
  • If x12, what is T?

16
Making Decisions
  • 100 Input x
  • 110 If xgt10 then T.5x
  • 120 Else Tx
  • If x6, what is T? T3
  • If x12, what is T? T12

17
Printing
  • 100 Let K8
  • 110 Print Tab(K)Tab(22-K)
  • 120 Let KK1
  • 130 If Klt10 Then 110
  • 140 Print Tab(11)
  • 150 END
  • RUN What?

18
Printing
  • 100 Let K8
  • 110 Print Tab(K)Tab(22-K)
  • 120 Let KK1
  • 130 If Klt10 Then 110
  • 140 Print Tab(11)
  • 150 END
  • RUN What?

19
OopsLoops!
  • 200 For I1 to N
  • 210 Print -
  • 220 Next I
  • Assume line 190 reads N15. What happens when
    the program is run?

20
OopsLoops!
  • 200 For I1 to N
  • 210 Print -
  • 220 Next I
  • Assume line 190 reads N15. What happens when
    the program is run?
  • --------------- (15 dashes)

21
Hurrays! (Arrays)
  • Variable G7
  • Array G4 G5 G6 G7
  • This format will confuse the computer!
  • What should we write?

22
Hurrays! (Arrays)
  • Variable G7
  • Array G4 G5 G6 G7
  • This format will confuse the computer!
  • What should we write?
  • G(1)4 G(2) 5 G(3)6 G(4)7

23
Hurrays! (Arrays)
  • What should we write?
  • G(1)4 G(2) 5 G(3)6 G(4)7

Every variable is an array.
24
Visual Basic
  • Visual Basic is related to Basic. Unlike Basic,
    Visual Basic is designed to have objects with
    properties and buttons which trigger events.
Write a Comment
User Comments (0)
About PowerShow.com