BASIC programs
This article is about arithmetical operator, mathematical operator, and character.
We already used / and +.
+ is plus.
/ is divide.
minus is -.
multiple is *.
Parentheses ( and ) have high priority.
Calculate order is multiple and divide -> plus and minus.
10 REM Calculate
20 LET I=5
30 LET J=2
40 PRINT I+J
50 PRINT I/J
60 PRINT I-J
70 PRINT I*J
80 PRINT (I+J) * 2
90 END
Then run,
7
2.5
3
10
14
We used LET statement in this program.
LET is a statement for an announcement.
10 LET I=5
means we use I equal 5.
Computer can calculate.
Computer can be a calculator.
Next is A$ (What we wanted to do was not CHAR$, what we wanted to do was A$).
10 REM Character
10 INPUT A$
20 PRINT A$
30 END
Then run,
If you input HELLO, then computer returns HELLO.
10 REM Small AI
20 INPUT A$
30 PRINT A$
40 GOTO 20
50 END
Then run, your computer will answer the same words for you.
Push Control key + C key will stop this program.
10 REM You can add characters
20 INPUT A$
30 INPUT B$
40 PRINT A$ + B$
50 END
(Program-6-20-2014)
Then run,
?
HELLO
?
WORLD
Computer will print HELLOWORLD.
Please learn deference of number and character.
If you run Program-6-20-2014, and,
?
2
?
5
Computer will print 25.
10 REM World Cup
20 INPUT A$
30 INPUT B$
40 INPUT C$
50 INPUT D$
60 PRINT A$ + B$ + C$ + D$
70 END
Then run,
?
Japan
?
Colombia
?
Cote d'Ivoire
?
Greece
Computer will show JapanColombiaCote d'IvoireGreece.
Homework: Write many BASIC programs with arithmetic operators. Make many flow charts for programs in this article and your programs.
10 REM Area for quadrangle
20 INPUT A
30 INPUT B
40 PRINT A*B
60 END
This program print area for quadrangle. (A is a height, B is a width)
10 REM Area for triangle
10 INPUT A
20 INPUT B
30 PRINT A*B / 2
40 END
This program print area for triangle. (A is a height, B is a width)
Homework: Make BASIC programs for many area calculations and many volume calculations in mathematics. Make all flow charts for your programs.
(R.S.F. toshiki speed news press, Agence France-Presse, 20 Friday June 2014 The Roman)
Be this World Cup will good memory for you.
(R.S.F. toshiki speed news press, Agence France-Presse, 20 Friday June 2014 The Roman)