﻿

# Anagrams

Anagrams are a common feature of crosswords and quiz programs such as Countdown and Only Connect. In this assignment you'll use the BASIC string manipulation functions to create anagrams. Anagrams are words that have the same letters as the original word, but in a different order.

## Commands

Here is a reminder of the commands you might need for this task.

• INPUT - e.g. INPUT "What is your name? "; A\$ will ask the question and store the answer in the variable called A\$

• FOR - repeats a section of your program a number of times - e.g. FOR N = 1 TO 10 will repeat 10 times, counting with N from 1 to 10. If you don't want to count in 1s, you can add STEP - e.g. FOR N = 5 TO 100 STEP 5 (to count up to 100 in 5s) or FOR N = 10 TO 1 STEP -1 (to count from 10 down to 1). You don't need to use N - it's just a programmers habit, like using x in algebra; any valid variable name will do.

• NEXT - goes after FOR, at the end of the section that you want to repeat.

• RND(1) - gives you a random number from 0 to 1, which can be printed or assigned to a variable, e.g. x = RND(1).

• LEN - returns the number of characters in a fixed or string variable, e.g. LEN("Hello") returns the value 5.

• MID\$ - returns a given number of characters from a string, starting at a specified character, e.g. MID\$("Hello", 2, 3) would return three characters from the string Hello, starting at the second character.

Your task is to produce a program to jumble words entered by the user and turn them into anagrams. Your program should:

1. ask the user for a word

2. jumble the word to form the anagram and print the result

3. be clear and easy to use

The minimum output is the anagram, but you can add extra text to make your program easier to understand.

### Extension

There are many ways in which you could extend this program. You could try taking a whole sentence as input and jumbling only the words, keeping the spaces in the same place to separate the words. Better still, you might have seen sentences where the letters of each word are jumbled, apart from the first and last letter, and the sentences are still readable - you could try to create a program to do that, e.g. to turn the input the quick brown fox jumped over the lazy dog into something like the qciuk borwn fox jepmud oevr the lzay dog.