Using INPUT
Another way to give the computer information is with the command INPUT.
INPUT lets you put
information into the
computer’s memory while
the program is running. This means that you can
give the computer different information,
each time you
run a program.
You always put a variable name after INPUT.
When the computer meets INPUT it
waits for you to type something and stores it in the named variable.
This computer tells you it is waiting by displaying a question mark.
NEW 10 CLS 20 PRINT "WHAT IS YOUR NAME?" 30 INPUT N$ 40 PRINT "HOW OLD ARE YOU?" 50 INPUT A 60 CLS 70 PRINT N$; " IS "; A 80 PRINT "YEARS OLD" RUN
Computer calculator
This is a challenge. Read these instructions carefully so you can get it right!
See if you can fill in the missing lines in this program. The program makes your computer work as a calculator. You type in two numbers and the computer adds them
together and puts the answer on the screen. You need to fill in lines 30 and 50 with INPUT commands, but read the whole program before
you start so you can see what you need to do.
NEW 10 CLS 20 PRINT "TYPE A NUMBER" 30 ?? 40 PRINT "TYPE ANOTHER NUMBER" 50 ?? 60 C=A+B 70 PRINT A;"+";B;"=";C RUN
Message program puzzle
Here is another program puzzle. When you run the program the computer asks for a message. Then it asks who the message is for and who is sending it.
The computer stores this information in variables A$,
B$ and M$. Then it clears the screen and displays the
message.
Can you complete the PRINT commands in lines 90 and 110
so the computer displays the names stored in A$ and B$, with the message?
NEW 10 CLS 20 PRINT "WHAT IS THE MESSAGE?" 30 INPUT M$ 40 PRINT "WHO IS IT FOR?" 50 INPUT A$ 60 PRINT "WHO IS IT FROM?" 70 INPUT B$ 80 CLS 90 PRINT 100 PRINT M$ 110 PRINT RUN