CSC3320 Assignment 1 25 points due 2/11/02 Dr. Harrison Spring 2002

This assignment consists of three short C-shell scripts. When complete it should be emailed to the GTA. His account is slp40@yamacraw.cs.gsu.edu.



  1. Write a short script that reverses the order of items in a list. It should read a line from standard input (i.e. the terminal) so that it can be used with a pipe as in

    "cat x.x | reverse"



  1. Write a short script to find an optimal rational expansion for sqrt(2). Take as input an integer which is the maximum denominator to use and find a numerator-denominator pair that minimizes abs( 2*denominator*denominator -numerator*numerator). In order to compare different denominators, you will need a scaled residual like maximum_denominator*2 - maximum_denominator*numerator*numerator/denominator/denominator. You will also have to be careful about the order of operations because of integer truncation. Example expansions are: 3/2 ,5/3, 6/4, 8/5,9/6 ...



  1. Based on problem 2, it is conjectured that there is always a perfect square between 2*(a_number_squared) and 3*(a_number_squared). Write a script to check this for the integers below a user specified maximum. (obviously you can't check it mechanically for all numbers).