Answer:

So far, variables have held numbers.

String Variables

The sequence of characters "Miles per Gallon" in the following program is a string:

LET MILES = 200
LET GALLONS = 10
PRINT MILES / GALLONS, "Miles per Gallon"
END

So far you have been using strings for labeling the output of your programs or for prompting the user to enter a number. This chapter will discuss more ways to use strings.

Computer programs that work with strings are very common. For example, word processing programs manipulate character data. These programs use string variables to hold the character data.

Remember what a variable is:

A variable is a small amount of computer memory that has been given a name. You (the programmer) think of the name you want to use. The QBasic system finds some memory for that name.

So far in this course you have been using numerical variables to store numbers in the computer's memory. For example, the variables GALLONS and MILES in the previous program are numerical variables.

A string variable is a variable that holds a character string. It is a section of memory that has been given a name by the programmer. The name looks like those variable names you have seen so far, except that the name of a string variable ends with a dollar sign, $.

The $ is part of the name. If you forget to put it at the end of a name, the QBasic system will think you want a numerical variable.

QUESTION 2:

Which of the following are correct names for string variables?