308-273A
Assignment #1
Due September 23 at 5pm

See the web page http: www.cs.mcgill.ca/~dudek/273.html for updates.

Notes:

Perform electronic submission with the following command:
handin cs273 ass1 file1 file2 file3

Your programs should be reasonably efficient and properly documented. This implies
bothcomments within the program itself (internal documentation) as well asa written
document that explains the objective of the program, its design, and how it was tested and
an indication re. its correctness (external documentation). Although UNIX man pages
provide rather less than this, observe that they serve as a crude example in that they contain
a synopsis of the program it's use and characteristics, and a ``feature'' and/or bug list.
Each program should run for the various inputs.

As usual, programming assignments should be submitted in the two
forms:
1. A print out of the programs and external documentation
with sample input/output data.
2. An electronic version submitted via the handin program.

Time remaining to complete the assignment:

Introduction

Parity is a simple technique for performing error checking on digital data. The basic
premise of almost all error-checking schemes is based on a careful selection of what binary
patterns are used to represent data of interest. Specifically, although an N-bit bit-pattern
can be used to represent up to 2^N different pattern, parity-encoding involves using only
2^(N-1) patterns for relevant data and, essentailly, reserves the remaining 2^(N-1) patterns
(half of the set of bit patterns) for error checking.

Specifically, parity encoding assures that the total number of bits in the encoding of a
number is always even (or odd, if ""odd parity" is used).

Task

  1. Write a C program to read in a number from the keyboard and print it in base 2 (binary),
    base 3 (trinary) and hexadecimal.
  1. Augment your program to print the numbers using even parity(so, for example, the number 2 in even-parity binary would be 1000000000000010). A 16-bit representation is a natural
    choice, but you may use any size over 8 bits, at your discretion.
  1. Write a C function that multiplies two numbers together. It must NOTuse the C
    multiplication operator, but must (rather) use only the shift left <<and shift right >>
    operators along with addition and conditional.