# CSCD-2552015-03-02

## Sequential Files (Ch. 28)

Link to the Lab 7 write-up

Links to the mandated main (as .txt for examination here and as .c)
cscd255Lab7.txt     cscd255Lab7.c

Modular arithmetic:  note that on the standard 12-hour clock face, the operation of backing up by three hours is exactly the same as going forward by 9 hours.

If the alphabet is considered as circular, then we can have the same behavior:  backing up by three positions is the same as going forward by 23 positions.

Unfortunately the "modulo" operator (`"%"`) is in fact a remainder operator — if the second argument is a negative number, it will return a negative number.  Instead we want to have a positive number that acts like that negative number.  There is a way to do that.

Assume that we want to truly get the "module 26" of a number.  If the shift is negative, that can be done thus:  its remainder will be in the range from -25 to -1, so bring it around just by adding 26.

```   if (shift < 0)       shift = shift%26 + 26;    new_offset = (old_offset + shift) % 26;```
```shift is initially -55
shift%26 gives -3
shift = shift%26 + 26
shift has changed to 23
old_offset of 13 transforms to new_offset of 10
which moves old_offset back by three positions```

## Exam 2 Information

Specimen exam — significantly longer than the one to be given on Wednesday.

Note that the lecture for 12 Feb contains drill programs on the version of selection sort we are covering in class.
drillSelSort.txt   drillSelSort2.txt

Also note that the lecture for 24 Feb ended with a program turning the first question on the sample exam into a drill.