In class Programming Exercises: Arrays

  1. Write a program that takes user-entered lines and stores them in an array. When the user enters "quit", the program prints out all the lines. Call it "prog2_1.pl".
    --To be a bit more explicit, use a while loop with and chomp to get user input, testing each entry for "quit". If the entry is ssomething else, use "push" to put in on the end of the array. Then, after the user enters "quit", break out of the while loop and print the array.
  2. Modify program 1 so that it prints out the lines in reverse order. Call it "prog2_2.pl".
  3. Modify program 1 so it first sorts the lines (ASCII order), then prints them out. Call it "prog2_3.pl".
  4. Modify the program so it tells you how many lines have been entered, and then prints out only lines 2, 3, and 4. Call it "prog2_4.pl".
  5. Write a program that adds up all the numbers between 1 and 50, and also adds up the squares of those numbers. Have it print out the results. prog2_5.pl.