Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
16
Task/Variables/BASIC/variables-1.basic
Normal file
16
Task/Variables/BASIC/variables-1.basic
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
10 LET A=1.3
|
||||
20 LET B%=1.3: REM The sigil indicates an integer, so this will be rounded down
|
||||
30 LET C$="0121": REM The sigil indicates a string data type. the leading zero is not truncated
|
||||
40 DIM D(10): REM Create an array of 10 digits
|
||||
50 DIM E$(5.10): REM Create an array of 5 strings, with a maximum length of 10 characters
|
||||
60 LET D(1)=1.3: REM Assign the first element of d
|
||||
70 LET E$(3)="ROSE": REM Assign a value to the third string
|
||||
80 PRINT D(3): REM Unassigned array elements have a default value of zero
|
||||
90 PRINT E$(3): REM Ten spaces because string arrays are not dynamic
|
||||
100 PRINT E$(3);"TTA CODE": REM There will be spaces between rose and etta
|
||||
110 DIM F%(10): REM Integers use less space than floating point values
|
||||
120 PRINT G: REM This is an error because f has not been defined
|
||||
130 PRINT D(0): REM This is an error because elements are numbered from one
|
||||
140 LET D(11)=6: REM This is an error because d only has 10 elements
|
||||
150 PRINT F%: REM This is an error because we have not provided an element number
|
||||
160 END
|
||||
15
Task/Variables/BASIC/variables-2.basic
Normal file
15
Task/Variables/BASIC/variables-2.basic
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
10 A = 1.7: REM LET IS NOT REQUIRED
|
||||
20 LET B% = 1.7: REM THE PERCENT SIGN INDICATES AN INTEGER; THIS GETS TRUNCATED DOWN
|
||||
30 LET C$ = "0121": REM THE DOLLAR SIGN INDICATES A STRING DATA TYPE. THE LEADING ZERO IS NOT TRUNCATED
|
||||
40 DIM D(20): REM CREATE AN ARRAY OF 21 FLOATING POINT NUMBERS
|
||||
50 DIM E$(5,10): REM CREATE A TWO DIMENSIONAL ARRAY OF 66 STRINGS
|
||||
60 LET D(1) = 1.3: REM ASSIGN THE SECOND ELEMENT OF D
|
||||
70 Y$(3) = "ROSE": REM ASSIGN A VALUE TO THE FOURTH STRING
|
||||
80 PRINT X: REM UNASSIGNED FLOATING POINT AND INTEGER VARIABLES HAVE A DEFAULT VALUE OF ZERO
|
||||
90 PRINT Y$(2): REM UNASSIGNED STRING VARIABLES ARE EMPTY
|
||||
100 PRINT Y$(3);"TTA CODE": REM THERE WON'T BE SPACES BETWEEN ROSE AND ETTA
|
||||
110 F%(10) = 0: REM IF ARRAYS ARE NOT DECLARED THEY HAVE 11 ELEMENTS BY DEFAULT; IE. DIM F%(10)
|
||||
120 PRINT G: REM THIS PRINTS 0 AND IS NOT AN ERROR EVEN THOUGH G HAS NOT BEEN DEFINED
|
||||
130 PRINT D(0): REM THIS IS NOT AN ERROR BECAUSE ELEMENTS ARE NUMBERED FROM ZERO.
|
||||
140 PRINT F%: REM THIS PRINTS 0 BECAUSE F% IS A DIFFERENT VARIABLE THAN THE ARRAY F%(10)
|
||||
150 LET D(21) = 6: REM THIS IS AN ERROR BECAUSE D ONLY HAS 21 ELEMENTS INDEXED FROM 0 TO 20.
|
||||
Loading…
Add table
Add a link
Reference in a new issue