Tuesday, 20 September 2016

INPUT

INPUT is a command that allows you or anybody else who runs the program to enter the information (text or number) when the program is already running. This command waits for the user to enter the information and then assigns this information to a variable. Since there are two types of variables, the INPUT command may look like this – 

INPUT a (for a number), or INPUT a$ (for a string).

Example (Type this program into QBasic and run it by pressing F5)

PRINT “What is your name?”
INPUT name$
PRINT “Hi, ”; name$; “, nice to see you!”
PRINT “How old are you?”
INPUT age
PRINT “So you are ”; age; “ years old!”
END

Note: The END command tells QBasic that the program ends here.
You don’t have to use PRINT to ask the user to enter the information. Instead, you can use

INPUT “Enter your name”; name$
and the result will be the same.

No comments:
Write comments