1. Write a program that will scan a C file and report: Solution

    1. Write a program that takes in two integer (x,y) co-ordinates, ignoring any spaces, and calculates the direct distance between them (using Pythagoras' theorem).

    2. A person wishes to control the movement of a robot using a simple language; the grammar is
      commmand -> commmand THEN commmand
       	| commmand AFTER commmand
       	| ( commmand )
       	| basic
      basic -> FORWARD n
      	| LEFT n
      	| RIGHT n 
      	| BACK n  
      
      where n is any positive whole number. The robot is always facing north, south, east or west; the meaning of the commands is as follows:

      c1 THEN c2 Perform c1 followed by c2
      c1 AFTER c2 Perform c2 followed by c1
      FORWARD n Move forward n steps
      LEFT n Turn left through 90o, and move n steps
      RIGHT n Turn right through 90o, and move n steps
      BACK n Turn through 180oand move n steps

      Assume that the robot starts in position (0,0) facing north. Write a program that calculates the distance a robot travels from the origin after a sequence of commands.

    Solution

  2. Write an infix to prefix translator for arithmetic expressions over positive whole numbers that use addition, multiplication and brackets. (The program should just output the expression in prefix form - you don't have to evaluate it).

    Solution: infix-to-prefix, infix-to-postfix