PS 2

  1. rand() gives a random, or strictly speaking pseudo-random, int between 0 and RAND_MAX, often the largest integer. Use rand() and % to print out a random number between one and seven.
  2. The Fortune Teller Fish is a party favor that comes in Christmas crackers, it is a red cellophane fish that twists or curls up when you put it on your hand, something to do with moisture. It purports to tell your fortune based on the shape it makes and answers one of Jealousy, Indifference, In Love, Fickle, False, Dead One and Passionate. Under the assumption all seven are equally likely, write a Fortune Teller Fish emulator, remember, you should use else if's as well as if's to avoid testing possibilities that have already been ruled out.
  3. char's are stored as short integers, basically between 0 and 127. The details of this encoding are historic but all the numbers from 32 to 127 correspond to printable symbols, the first 32 were reserves for control characters, characters used to control printers and such. Most of these early characters are now obsolete, some are still used for carriage returns, tabs and such like. By casting int to char print out the 96 printable symbols. Use a double loop to print them out as in an array rather than a long list.
  4. The do/while loop is like a while loop except it tests the condition at the end:
          do
          {
           STATEMENTS;
          }
          while(CONDITION);
    
    The advantage is that you do the loop at least once. Write a programme that says "Input any word that isn't pointless" and keeps asking until you enter a word that isn't "pointless" and the programme finishes.