Computer Science, asked by mazumdersoydul, 4 months ago

how is the INKEY$ command different from the INPUT command?​

Answers

Answered by Anonymous
4

Answer:

.The INPUT command is used to gather input from the user. This section will attempt to teach you how to gather input upon request from the user. ... When a semicolon (;) is used after the text output to the user, a question mark (?) and space ( ) are added to the output. When a comma (,) is used, no question mark is added.

Answered by Mohit18306
1

Inputting data

This chapter describes several methods by which you can input data into your BASIC program:

from the keyboard

from predefined data within your program

by programming keys on the keyboard

from a mouse.

Inputting data from the keyboard

There are three commands you can use to input data from the keyboard:

The INPUT command allows a program to request information.

The GET command waits for the user to press a single key.

The INKEY command waits a specified length of time for the user to press a single key.

Note that you are advised not to use these three commands in BASIC programs written under the window manager environment (see the Window managed programs section).

INPUT

The INPUT statement allows a program to request information from the user.

The following program gives an example:

10 PRINT "Give me a number and I'll double it";

20 INPUT X

30 PRINT "Twice ";X " is ";X*2

When you run this program, the INPUT command on line 20 displays a question mark on the screen and waits for you to enter data. The number you type is assigned to the variable X. If you do not type anything, or type letters or symbols instead, X is assigned the value 0.

INPUT may also be used with string and integer variables:

10 PRINT "What is your name ";

20 INPUT A$

30 PRINT "Hello ";A$

Line 10 in each of the above two programs is used to print a message on the screen indicating the type of response required. The INPUT statement allows text prompts to be included, so the program above could be written more neatly as:

10 INPUT "What is your name ",A$

20 PRINT "Hello ";A$

The comma in line 10 tells the computer to print a question mark when it wants input from the keyboard. If you leave out the comma, the question mark is not printed. A semi-colon may be used, with exactly the same effect as the comma.

When the program is being executed, the INPUT statement requires you to press Return if you wish to send what you have typed to the computer. Until you press Return, you can delete all or part of what you have typed by pressing Delete or Ctrl-U to erase the whole line.

When you are inputting a string, the computer ignores any leading spaces and anything after a comma, unless you put the whole string inside quotation marks.

To input a whole line of text, including commas and leading spaces, INPUT LINE (or LINE INPUT) may be used:

10 INPUT A$

20 INPUT LINE B$

30 PRINT A$

40 PRINT B$

RUN the above program and, in response to each of the question marks, type

Hello, how are you?

This produces the following output:

Hello

Hello, how are you?

Several inputs may be requested at one time:

10 INPUT A,B,C$

You may enter the data individually, pressing Return after each item. In this case you are prompted with a question mark until you enter the number required. Alternatively, you can give all the inputs on one line, separated by commas.

Similar questions