CST 8110 - Assignment Nine

A one-page print-out of this program is due in my assignment box by 10:45am Friday, June 27.

All assignments are evaluated based on their neatness and how closely they follow the assignment submission guidelines published in the online course notes.

Purpose and Instructions

This program illustrates how bits are just bits; the same bit pattern in memory can be interpreted as many different things. You, the programmer, must know the limitations of the storage types you select.

Write a C program that reads in one integer ("%d") and prints the value read in in five output formats: signed integer ("%d"), unsigned integer ("%u"), character ("%c"), hexadecimal ("%x") and octal ("%o"). The output from the program should look something like this, only nicer:

Signed integer: -32704
Unsigned integer: 32832
Character: @
Hexadecimal: 8040
Octal: 100100

Create a second version of the program that reads in a hexadecimal number ("%x") and produces the same five output formats. Create a third version of the program that reads in an octal number ("%o") and produces the same five output formats. Verify that each program produces the correct output.

What happens if you enter numbers larger than can be stored in the two-byte integer?

Hand in: The one-page version of your program that reads hexadecimal numbers. No cover page is necessary; your Algonquin program header will have all the required information.

As always, the program must follow Algonquin standards for headers and format. The algorithm you design to solve the problem must use pseudocode where appropriate.


The aggregate of all assignment marks comprises 25% of your final mark. All assignments must be completed satisfactorily to get credit for the course, even if the assignments are submitted too late to receive a mark. (See the course outline.)

Late assignments are handled according to the policy given in the course outline.