ECE-1021

HOMEWORK #1

(Last Mod: 27 November 2010 21:38:39 )

ECE-1021 Course Homepage

ECE-1021 Semester Homepage


Objectives


Assignment

Write a program that prints a table of all of the ASCII codes with each column containing information as follows:

  1. Integer Value (in decimal)

  2. Character/name (name is the 2- or 3- letter abbreviation for the non-graphing characters)

  3. Is the character is a valid ASCII character (isascii())

  4. Is the character is a control character (iscntrl())

  5. Is the character a printing character (isprint())

  6. Is the character a graphical character (isgraph())

  7. Is the character a white-space character (isspace())

  8. Is the character a punctuation character (ispunct())

  9. Is the character a decimal digit (isdigit())

  10. Is the character a hexadecimal decimal (isxdigit())

  11. Is the character an alphanumeric character (isalnum())

  12. Is the character an alphabetic character (isalpha())

  13. Is the character an uppercase character (isupper())

  14. Is the character a lowercase character (islower())

  15. The uppercase version of the character (toupper())

  16. The lowercase version of the character (tolower())

In any column where the actual characters are printed - except the one containing the names - you should print a period in place of the character if the character is a non-graphical character.

The values in all but the first two and last two columns should be based on functions that return a logical value depending on the ASCII code that is passed to them. The value should be a 'T' if the function returns a logical True and should be a hyphen if it returns a logical False.

The last two columns should call functions that convert an upper case character to lower case (or vice-versa) if the character is alphabetic and returns the character unchanged if it is not alphabetic.

Each column should have a heading. The heading for the first two columns are "value" and "name" respectively. The headings for all other columns are the names of the functions used in that column (there is no need to include the parentheses that follow the function name). In order to get all of the columns to fit within the width of the screen, the names will need to be printed vertically - i.e., each succeeding line contains the next character from that column's heading.

Other than PrintHeader(), the only function from any standard library that your code may call, either directly or indirectly, is putc().  This means that you may use the printc() function defined in the C Source Code Template since it only uses putc().

Your program should be well-modularized with no one function requiring more than approximately one screen (25 lines) to display. This is not an absolutely rigid limitation, but functions longer than that should have a reason for being so and should be kept to the minimum length practicable. The one function that you will find reasonable to violate this limitation on is the one that prints out the names of the control characters. This is an ideal situation for a switch() statement with one case label for each of the control characters plus the space character.

HINT: Printing the column headings is not difficult, but it is time consuming because you need to do much of it in a very brute force manner. Leave it for last. Get the table printing out correctly and formatted properly and then add in the column headings.