SIBT COMP 125

Week 8 Practical Exercises

Even though you are studying for, or recovering from, the mid-semester exam, we still need to keep up with exercises related to the lecture material. This weeks prac exercise is short and simple. When you finish this, you can work on Assignment 2. Be warned, however, that we will not answer questions related to the assignment until this work is done. This should be good motivation to try doing this at home, before the practical session.

1. Write a program which reads 10 integers from input, and then displays the integers in ascending order. You can use the Selection_Sort code from lectures.

2. Homework: Write a program which reads 10 strings from input, and print the strings in ascending lexicographic order. You will need to write a selection sort that works for strings. There are two ways to do this. Firstly, you could work out the numerical values of the first letter of each word and compare them (and if they are the same, you can add the value of the second letter, etc.). Secondly, you could use some features of the string and/or character class to determine which one is alphabetically superior.