Example:

PRINT RND (19)

press ENTER

 

 

You will get a number between 1 and 19. RND (0) will give you a number between 0 and 1.

Note: X cannot be negative.

Important Note: From now on, the ENTER key sign will be deleted for simplicity. Remember to press the ENTER key after each line of entry.

STRING FUNCTIONS

We can also use functions to act on strings. Take a look at the following:

LEN

This function computes the length of the string argument, which must be in brackets. So if you type PRINT LEN (“JOHN”) the computer will return the result 4. This is telling you that there are 4 characters in the string “JOHN”. Blank spaces have the value of characters. Thus if you put in spaces “J O H N”, it comes out as 7 characters.

STR$

The STR$ function changes a number argument into a string. Take a look at the following example and see how it works.

Example:

A$=STR$(73)

This is the same as saying A$=“73”.

Here is a sample program.

Type the next example:

10A$=STR$(7*3)

20B$=A$+“BIG”

30PRINT B$

RUN 21BIG

53